summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-24 16:08:11 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-24 16:08:11 +0000
commit5791999fefcf73fcef43d5b590dee1113be5c3af (patch)
treeca710a32b2afc2a6652c1ba80891b326e6c26420
parente06f9c34bb68d44431d2d4f55ab9bd5089331b64 (diff)
downloadgcc-5791999fefcf73fcef43d5b590dee1113be5c3af.tar.gz
PR tree-optimization/36008
* fold-const.c (try_move_mult_to_index): If s == NULL, divide the original op1, rather than delta by step. * gcc.c-torture/execute/20080424-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134634 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20080424-1.c31
4 files changed, 43 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 31bac1edbcd..5751c5d10df 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/36008
+ * fold-const.c (try_move_mult_to_index): If s == NULL, divide
+ the original op1, rather than delta by step.
+
2008-04-22 Antoniu Pop <antoniu.pop@gmail.com>
Sebastian Pop <sebastian.pop@amd.com>
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 4015f62e5cd..a4d5760b861 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6919,7 +6919,7 @@ try_move_mult_to_index (tree addr, tree op1)
else
{
/* Try if delta is a multiple of step. */
- tree tmp = div_if_zero_remainder (EXACT_DIV_EXPR, delta, step);
+ tree tmp = div_if_zero_remainder (EXACT_DIV_EXPR, op1, step);
if (! tmp)
continue;
delta = tmp;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fa3768efc2e..01c423c6667 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/36008
+ * gcc.c-torture/execute/20080424-1.c: New test.
+
2008-04-24 Ira Rosen <irar@il.ibm.com>
Richard Guenther <rguenther@suse.de>
diff --git a/gcc/testsuite/gcc.c-torture/execute/20080424-1.c b/gcc/testsuite/gcc.c-torture/execute/20080424-1.c
new file mode 100644
index 00000000000..4916d907565
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20080424-1.c
@@ -0,0 +1,31 @@
+/* PR tree-optimization/36008 */
+
+extern void abort (void);
+
+int g[48][3][3];
+
+void __attribute__ ((noinline))
+bar (int x[3][3], int y[3][3])
+{
+ static int i;
+ if (x != g[i + 8] || y != g[i++])
+ abort ();
+}
+
+static inline void __attribute__ ((always_inline))
+foo (int x[][3][3])
+{
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ int k = i + 8;
+ bar (x[k], x[k - 8]);
+ }
+}
+
+int
+main ()
+{
+ foo (g);
+ return 0;
+}