re PR tree-optimization/36008 (Function produces wrong results when inlined.)
authorJakub Jelinek <jakub@redhat.com>
Thu, 24 Apr 2008 16:08:11 +0000 (18:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 24 Apr 2008 16:08:11 +0000 (18:08 +0200)
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.

From-SVN: r134634

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20080424-1.c [new file with mode: 0644]

index 31bac1edbcdaac1668775af9cd43c88db0c1c9eb..5751c5d10dfb2a0db57c69659b52d8d0a8c4c3ff 100644 (file)
@@ -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>
 
index 4015f62e5cd0425089c6d2b6afee81e3dedd9730..a4d5760b8619c9409844315f0d8b91ed78bb709d 100644 (file)
@@ -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;
index fa3768efc2e8e0bbe2f4c3e4e4b05b5c976f656a..01c423c66678b6bc6a783e8406e68a7b5380ec15 100644 (file)
@@ -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 (file)
index 0000000..4916d90
--- /dev/null
@@ -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;
+}