diff mbox series

Fix reassoc leaving * 0 in the IL.

Message ID alpine.LSU.2.20.1901231458490.23386@zhemvz.fhfr.qr
State New
Headers show
Series Fix reassoc leaving * 0 in the IL. | expand

Commit Message

Richard Biener Jan. 23, 2019, 2:01 p.m. UTC
$subject - on trunk the PR is hidden because those do not appear
for other reasons.  Still stray * 0 are prone to causing failures
thus the following.

On the branches this hides the SLSR bug.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk
sofar.

Richard.

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.
diff mbox series

Patch

Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c	(revision 268182)
+++ gcc/tree-ssa-reassoc.c	(working copy)
@@ -1015,7 +1015,7 @@  eliminate_using_constants (enum tree_cod
 		    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;
 		}
Index: gcc/testsuite/gcc.dg/torture/pr89008.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr89008.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr89008.c	(working copy)
@@ -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;
+}