re PR middle-end/89008 (O2 and O1 results differ for simple test)
authorRichard Biener <rguenther@suse.de>
Wed, 23 Jan 2019 14:02:13 +0000 (14:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 23 Jan 2019 14:02:13 +0000 (14:02 +0000)
2019-01-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89008
* tree-ssa-reassoc.c (eliminate_using_constants): For * 0 do
not leave another stray operand.

* gcc.dg/torture/pr89008.c: New testcase.

From-SVN: r268186

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr89008.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index 47bb6813b8e7965a20bf5e277899cbf7ff309934..bbbacebf4cbed90d345126e73caa837ba8e4317a 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89008
+       * tree-ssa-reassoc.c (eliminate_using_constants): For * 0 do
+       not leave another stray operand.
+
 2019-01-23  Jakub Jelinek  <jakub@redhat.com>
 
        * BASE-VER: Bump to 9.0.1.
index b1ad37201af58a561204ecafa237677a6763f18a..d91be29b4fc16e0556ada6e96c624141c2f60d74 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89008
+       * gcc.dg/torture/pr89008.c: New testcase.
+
 2019-01-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/specs/opt4.ads: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr89008.c b/gcc/testsuite/gcc.dg/torture/pr89008.c
new file mode 100644 (file)
index 0000000..aa13f94
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+unsigned long a, c;
+unsigned b;
+int d, e;
+long f()
+{
+  unsigned long g = 0;
+  for (d = 0; d < 5; d += 2)
+    for (e = 0; e < 5; e += 3)
+      {
+       c = 4 + b;
+       g = -b - b;
+       b = 5 * (b << 24);
+      }
+  a = g;
+  return 0;
+}
+
+int main()
+{
+  f();
+  if (a)
+    __builtin_abort();
+  return 0;
+}
index 07ff42e2d55781ce64b7ebf86d289d0b8a602e08..e1c4dfe537eff8ff2d14af315a80e687e6361bf3 100644 (file)
@@ -1015,7 +1015,7 @@ eliminate_using_constants (enum tree_code opcode,
                    fprintf (dump_file, "Found * 0, removing all other ops\n");
 
                  reassociate_stats.ops_eliminated += ops->length () - 1;
-                 ops->truncate (1);
+                 ops->truncate (0);
                  ops->quick_push (oelast);
                  return;
                }