apply unary op to both sides of (vec_cond x cst1 cst2)

2019-05-31  Marc Glisse  <marc.glisse@inria.fr>

gcc/
	* match.pd (~(vec?cst1:cst2)): New transformation.

gcc/testsuite/
	* g++.dg/tree-ssa/cprop-vcond.C: New file.

From-SVN: r271817
This commit is contained in:
Marc Glisse 2019-05-31 19:04:20 +02:00 committed by Marc Glisse
parent 9cf60d3b0d
commit 34a13a521e
4 changed files with 35 additions and 0 deletions

View file

@ -1,3 +1,7 @@
2019-05-31 Marc Glisse <marc.glisse@inria.fr>
* match.pd (~(vec?cst1:cst2)): New transformation.
2019-05-31 Marc Glisse <marc.glisse@inria.fr>
* match.pd (X/[ex]D<Y/[ex]D): Handle negative denominator.

View file

@ -2920,6 +2920,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(if (integer_zerop (@0))
@2)))
/* Sink unary operations to constant branches, but only if we do fold it to
constants. */
(for op (negate bit_not abs absu)
(simplify
(op (vec_cond @0 VECTOR_CST@1 VECTOR_CST@2))
(with
{
tree cst1, cst2;
cst1 = const_unop (op, type, @1);
if (cst1)
cst2 = const_unop (op, type, @2);
}
(if (cst1 && cst2)
(vec_cond @0 { cst1; } { cst2; })))))
/* Simplification moved from fold_cond_expr_with_comparison. It may also
be extended. */
/* This pattern implements two kinds simplification:

View file

@ -1,3 +1,7 @@
2019-05-31 Marc Glisse <marc.glisse@inria.fr>
* g++.dg/tree-ssa/cprop-vcond.C: New file.
2019-05-31 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/cmpexactdiv-3.c: New file.

View file

@ -0,0 +1,12 @@
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-forwprop1-raw" } */
typedef long vec __attribute__((vector_size(2*sizeof(long))));
void f(vec*v){
vec t = { 5, 16 };
vec f = { 27, -11 };
vec r = *v ? t : f;
*v = -r;
}
/* { dg-final { scan-tree-dump-not "negate_expr" "forwprop1" } } */