diff options
author | Richard Biener <rguenther@suse.de> | 2016-05-24 14:35:36 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-05-24 14:35:36 +0000 |
commit | e5328f5dc2bc46eedf1d367de0bd751d43f1311d (patch) | |
tree | 3e7c51013c73ad079750221df2bef6bfcd99e8ad /gcc | |
parent | fce57248c89d5b990d1f82a2f8eba5a9741c9ad9 (diff) | |
download | gcc-e5328f5dc2bc46eedf1d367de0bd751d43f1311d.zip gcc-e5328f5dc2bc46eedf1d367de0bd751d43f1311d.tar.gz gcc-e5328f5dc2bc46eedf1d367de0bd751d43f1311d.tar.bz2 |
re PR tree-optimization/71230 (ICE : in zero_one_operation, at tree-ssa-reassoc.c:1230)
2016-05-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/71230
* tree-ssa-reassoc.c (zero_one_operation): Handle negate special ops.
* gcc.dg/torture/pr71230.c: New testcase.
* g++.dg/torture/pr71230.C: Likewise.
From-SVN: r236643
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr71230.C | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr71230.c | 25 | ||||
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 28 |
5 files changed, 89 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6eac48e..13134d9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-05-24 Richard Biener <rguenther@suse.de> + + PR tree-optimization/71230 + * tree-ssa-reassoc.c (zero_one_operation): Handle negate special ops. + 2016-05-24 Richard Sandiford <richard.sandiford@arm.com> * tree-vectorizer.h (vectorizable_comparison): Delete. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 361fbbd..a6f65b8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-05-24 Richard Biener <rguenther@suse.de> + + PR tree-optimization/71230 + * gcc.dg/torture/pr71230.c: New testcase. + * g++.dg/torture/pr71230.C: Likewise. + 2016-05-24 Thomas Schwinge <thomas@codesourcery.com> * c-c++-common/goacc/routine-5.c: Add tests. diff --git a/gcc/testsuite/g++.dg/torture/pr71230.C b/gcc/testsuite/g++.dg/torture/pr71230.C new file mode 100644 index 0000000..40ce55a --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr71230.C @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-additional-options "-ffast-math" } + +template <int rank, int dim> class Tensor; +template <int dim> class Point { +public: + Point (const double x, const double y, const double z); + double operator () (const unsigned int index) const; +}; +template <int celldim, int dim> class TriaObjectAccessor { + Point<dim> & vertex (const unsigned int i) const; + Point<dim> barycenter (double, double, double, double, double) const; +}; +template <> Point<3> TriaObjectAccessor<3, 3>::barycenter (double s6, double s7, double s1, double s2, double s3) const +{ + const double x[8] = { + vertex(0)(0), vertex(1)(0), vertex(2)(0), vertex(3)(0), vertex(4)(0), vertex(5)(0), vertex(6)(0), vertex(7)(0) }; + const double y[8] = { + vertex(0)(1), vertex(1)(1), vertex(2)(1), vertex(3)(1), vertex(4)(1), vertex(5)(1), vertex(6)(1), vertex(7)(1) }; + const double z[8] = { + vertex(0)(2), vertex(1)(2), vertex(2)(2), vertex(3)(2), vertex(4)(2), vertex(5)(2), vertex(6)(2), vertex(7)(2) }; + double s4, s5, s8; + const double unknown0 = s1*s2; + const double unknown1 = s1*s2; + s8 = -z[2]*x[1]*y[2]*z[5]+z[2]*y[1]*x[2]*z[5]-z[2]*z[1]*x[2]*y[5]+z[2]*z [1]*x[5]*y[2]+2.0*y[5]*x[7]*z[4]*z[4]-y[1]*x[2]*z[0]*z[0]+x[0]*y[3]*z[7]*z[7] -2.0*z[5]*z[5]*x[4]*y[1]+2.0*z[5]*z[5]*x[1]*y[4]+z[5]*z[5]*x[0]*y[4]-2.0*z[2]*z [2]*x[1]*y[3]+2.0*z[2]*z[2]*x[3]*y[1]-x[0]*y[4]*z[7]*z[7]-y[0]*x[3]*z[7]*z[7]+x [1]*y[0]*z[5]*z[5]; + s5 = s8+z[2]*x[6]*y[2]*z[5]-z[2]*x[5]*y[2]*z[6]-z[2]*x[2]*y[3]*z[7]-x[2]* y[3]*z[7]*z[7]+2.0*z[2]*x[2]*y[3]*z[1]-z[2]*y[2]*x[3]*z[0]+z[2]*y[2]*x[0]*z[3]- z[2]*x[2]*y[0]*z[3]-z[7]*y[2]*x[7]*z[3]+z[7]*z[2]*x[7]*y[3]+z[7]*x[2]*y[7]*z[3] +z[6]*y[1]*x[2]*z[5]-z[6]*x[1]*y[2]*z[5]+z[5]*x[1]*y[5]*z[2]+s6+s7; + s4 = 1/s5; + s2 = s3*s4; + const double unknown2 = s1*s2; + return Point<3> (unknown0, unknown1, unknown2); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr71230.c b/gcc/testsuite/gcc.dg/torture/pr71230.c new file mode 100644 index 0000000..d0df8da --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71230.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-ffast-math" } */ + +void metric_carttosphere(int *cctk_lsh, double txz, double tyz, double txx, + double tzz, double sint, double cosp, double cost, + double tyy, double sinp, double txy, double *grp, + double *grq, double *r) +{ + int i; + for(i=0; i<cctk_lsh[0]*cctk_lsh[1]*cctk_lsh[2]; i++) + { + grq[i] = (cost*tyy*((sinp)*(sinp))*sint+ + 2*cosp*cost*txy*sinp*sint- + cost*tzz*sint+ + ((cosp)*(cosp))*cost*txx*sint+ + 2*((cost)*(cost))*tyz*sinp- + tyz*sinp+ + 2*cosp*((cost)*(cost))*txz- + cosp*txz)*r[i]; + grp[i] = ((-txy*((sinp)*(sinp))+ + (cosp*tyy-cosp*txx)*sinp+ + ((cosp)*(cosp))*txy)*sint- + cost*txz*sinp+cosp*cost*tyz); + } +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 28823a2..3b02667 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1189,12 +1189,20 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op) { tree name; - if (opcode == MULT_EXPR - && stmt_is_power_of_op (stmt, op)) + if (opcode == MULT_EXPR) { - if (decrement_power (stmt) == 1) - propagate_op_to_single_use (op, stmt, def); - return; + if (stmt_is_power_of_op (stmt, op)) + { + if (decrement_power (stmt) == 1) + propagate_op_to_single_use (op, stmt, def); + return; + } + else if (gimple_assign_rhs_code (stmt) == NEGATE_EXPR + && gimple_assign_rhs1 (stmt) == op) + { + propagate_op_to_single_use (op, stmt, def); + return; + } } name = gimple_assign_rhs1 (stmt); @@ -1213,7 +1221,8 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op) } /* We might have a multiply of two __builtin_pow* calls, and - the operand might be hiding in the rightmost one. */ + the operand might be hiding in the rightmost one. Likewise + this can happen for a negate. */ if (opcode == MULT_EXPR && gimple_assign_rhs_code (stmt) == opcode && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME @@ -1226,6 +1235,13 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op) propagate_op_to_single_use (op, stmt2, def); return; } + else if (is_gimple_assign (stmt2) + && gimple_assign_rhs_code (stmt2) == NEGATE_EXPR + && gimple_assign_rhs1 (stmt2) == op) + { + propagate_op_to_single_use (op, stmt2, def); + return; + } } /* Continue walking the chain. */ |