aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-04-15 16:56:36 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2013-04-15 16:56:36 +0200
commit7b8265ba384990c3ba844abb0568bb8e770e06bc (patch)
tree68db4238d01907323ffd8be56274c39a178d9624
parent5185d248d5a554d394c80126646160abbf4f0bfa (diff)
downloadgcc-7b8265ba384990c3ba844abb0568bb8e770e06bc.zip
gcc-7b8265ba384990c3ba844abb0568bb8e770e06bc.tar.gz
gcc-7b8265ba384990c3ba844abb0568bb8e770e06bc.tar.bz2
re PR tree-optimization/56962 (SLSR caused miscompilation of fftw)
PR tree-optimization/56962 * gimple-ssa-strength-reduction.c (record_increment): Only set initializer if gimple_assign_rhs_code is {,POINTER_}PLUS_EXPR and either rhs1 or rhs2 is equal to c->base_expr. * gcc.c-torture/execute/pr56962.c: New test. From-SVN: r197978
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimple-ssa-strength-reduction.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr56962.c30
4 files changed, 50 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index db1b373..58f811e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2013-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56962
+ * gimple-ssa-strength-reduction.c (record_increment): Only set
+ initializer if gimple_assign_rhs_code is {,POINTER_}PLUS_EXPR and
+ either rhs1 or rhs2 is equal to c->base_expr.
+
2013-04-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/56933
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 873b8bc..57b343a 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -1829,16 +1829,20 @@ record_increment (slsr_cand_t c, double_int increment)
if (c->kind == CAND_ADD
&& c->index == increment
&& (increment.sgt (double_int_one)
- || increment.slt (double_int_minus_one)))
+ || increment.slt (double_int_minus_one))
+ && (gimple_assign_rhs_code (c->cand_stmt) == PLUS_EXPR
+ || gimple_assign_rhs_code (c->cand_stmt) == POINTER_PLUS_EXPR))
{
- tree t0;
+ tree t0 = NULL_TREE;
tree rhs1 = gimple_assign_rhs1 (c->cand_stmt);
tree rhs2 = gimple_assign_rhs2 (c->cand_stmt);
if (operand_equal_p (rhs1, c->base_expr, 0))
t0 = rhs2;
- else
+ else if (operand_equal_p (rhs2, c->base_expr, 0))
t0 = rhs1;
- if (SSA_NAME_DEF_STMT (t0) && gimple_bb (SSA_NAME_DEF_STMT (t0)))
+ if (t0
+ && SSA_NAME_DEF_STMT (t0)
+ && gimple_bb (SSA_NAME_DEF_STMT (t0)))
{
incr_vec[incr_vec_len].initializer = t0;
incr_vec[incr_vec_len++].init_bb
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4613593..af446d7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/56962
+ * gcc.c-torture/execute/pr56962.c: New test.
+
2013-04-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/56933
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr56962.c b/gcc/testsuite/gcc.c-torture/execute/pr56962.c
new file mode 100644
index 0000000..7c6da48
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr56962.c
@@ -0,0 +1,30 @@
+/* PR tree-optimization/56962 */
+
+extern void abort (void);
+long long v[144];
+
+__attribute__((noinline, noclone)) void
+bar (long long *x)
+{
+ if (x != &v[29])
+ abort ();
+}
+
+__attribute__((noinline, noclone)) void
+foo (long long *x, long y, long z)
+{
+ long long a, b, c;
+ a = x[z * 4 + y * 3];
+ b = x[z * 5 + y * 3];
+ c = x[z * 5 + y * 4];
+ x[y * 4] = a;
+ bar (&x[z * 5 + y]);
+ x[z * 5 + y * 5] = b + c;
+}
+
+int
+main ()
+{
+ foo (v, 24, 1);
+ return 0;
+}