]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/33714 (ivopts miscompiles insn-output.c)
authorZdenek Dvorak <ook@ucw.cz>
Fri, 12 Oct 2007 22:26:47 +0000 (00:26 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Fri, 12 Oct 2007 22:26:47 +0000 (22:26 +0000)
PR tree-optimization/33714
* tree-ssa-loop-ivopts.c (constant_multiple_of): Pass the arguments to
division in the correct order.

* gcc.dg/tree-ssa/pr33714.c: New test.

From-SVN: r129277

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr33714.c [new file with mode: 0644]
gcc/tree-ssa-loop-ivopts.c

index c5a4319df779fd26d0b4b5c0ca9b977d7bc23796..710fa5b724e0b2dc6e4d30f1e31374fb4cca8a66 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-12  Zdenek Dvorak <ook@ucw.cz>
+
+       PR tree-optimization/33714
+       * tree-ssa-loop-ivopts.c (constant_multiple_of): Pass the arguments to
+       division in the correct order.
+
 2007-10-10  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/25309
index 71474bb1ec196f5ace3d452dd5179ca1bb4ab2ad..7ffdf38aec723596b978620ab9f87b5993071912 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-12  Zdenek Dvorak <ook@ucw.cz>
+
+       PR tree-optimization/33714
+       * gcc.dg/tree-ssa/pr33714.c: New test.
+
 2007-10-10  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/25309
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr33714.c b/gcc/testsuite/gcc.dg/tree-ssa/pr33714.c
new file mode 100644 (file)
index 0000000..837bc8d
--- /dev/null
@@ -0,0 +1,59 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+struct rtx_def
+{
+  int mode : 8;
+  union {
+    long long hwint[1];
+  } u;
+};
+typedef struct rtx_def *rtx;
+
+void useme (long long int i) __attribute__((noinline));
+void do_something (void *) __attribute__((noinline));
+rtx get_rtx (int) __attribute__((noinline));
+void output_766 (rtx *operands,int) __attribute__((noinline));
+
+int target_flags;
+
+int global_count;
+void useme (long long int i __attribute__((unused)))
+{
+  global_count++;
+}
+
+rtx get_rtx (int i) { return i?0:0; }
+void do_something (void *p __attribute__((unused))) { global_count++;}
+
+void
+output_766 (rtx *operands, int ival)
+{
+  int i;
+  for (i = ival; i >= ((operands[2])->u.hwint[0]); i--)
+    {
+      useme(i*16);
+      operands[5] = get_rtx (i <= 7 ? i+1 : i+2);
+      operands[4]->mode = 15;
+      do_something (operands);
+    }
+}
+
+extern void abort(void);
+int main(void)
+{
+  rtx operands[6];
+  struct rtx_def rtx2, rtx4;
+  target_flags = 1 << 2;
+  operands[0] = 0;
+  operands[1] = 0;
+  operands[3] = 0;
+  operands[5] = 0;
+  operands[2] = &rtx2;
+  operands[4] = &rtx4;
+  rtx2.u.hwint[0] = 0;
+  output_766 (operands, 7);
+  if (global_count != 16)
+    abort();
+  return 0;
+}
index de84fa57d54736700fe05b7049e19d08a1ec381c..87f94e606edae0089fbe7ee8193f120b97fe6a58 100644 (file)
@@ -2608,8 +2608,8 @@ constant_multiple_of (tree top, tree bot, double_int *mul)
       if (TREE_CODE (bot) != INTEGER_CST)
        return false;
 
-      p0 = double_int_sext (tree_to_double_int (bot), precision);
-      p1 = double_int_sext (tree_to_double_int (top), precision);
+      p0 = double_int_sext (tree_to_double_int (top), precision);
+      p1 = double_int_sext (tree_to_double_int (bot), precision);
       if (double_int_zero_p (p1))
        return false;
       *mul = double_int_sext (double_int_sdivmod (p0, p1, FLOOR_DIV_EXPR, &res),