This PR seems to be curable by fixing up the CFG a little earlier. Bootstrapped and tested on x86_64-linux, and it seems to cure the testcase with a ppc cross. I'd appreciate if someone ran full ppc tests with this though. Ok?

Bernd
	PR rtl-optimization/79194
	* cprop.c (one_cprop_pass): Move deletion of code after unconditional
	traps before call to bypass_conditional_jumps.

	PR rtl-optimization/79194
	* gcc.dg/torture/pr79194.c: New test.

Index: gcc/cprop.c
===================================================================
--- gcc/cprop.c	(revision 244817)
+++ gcc/cprop.c	(working copy)
@@ -1863,8 +1863,6 @@ one_cprop_pass (void)
 	      }
 	}
 
-      changed |= bypass_conditional_jumps ();
-
       while (!uncond_traps.is_empty ())
 	{
 	  rtx_insn *insn = uncond_traps.pop ();
@@ -1873,6 +1871,8 @@ one_cprop_pass (void)
 	  emit_barrier_after_bb (to_split);
 	}
 
+      changed |= bypass_conditional_jumps ();
+
       FREE_REG_SET (reg_set_bitmap);
       free_cprop_mem ();
     }
Index: gcc/testsuite/gcc.dg/torture/pr79194.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr79194.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr79194.c	(working copy)
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+
+int iw, vr;
+
+void
+d9 (unsigned int j3, long long int f5, int kp)
+{
+  int *qb = &kp;
+
+  if (kp != 0)
+    {
+      long long int oq;
+      unsigned int tl = 0;
+
+      for (j3 = 0; j3 < 1; ++j3)
+        qb = &tl;
+      goto ed;
+
+ l7:
+      oq = 1;
+      while (oq < 2)
+        oq *= j3;
+
+ ed:
+      do
+        {
+          oq -= *qb;
+          if (oq != 0)
+            {
+              long long int ie = j3 & f5;
+              int ws = (j3 != 0 && kp != 0);
+
+              tl = ie > ws;
+              iw = vr = tl;
+            }
+          else
+            tl = (kp != 0 && (0 % 0) != 0); /* { dg-warning "division by zero" } */
+        }
+      while (tl != 0);
+    }
+  goto l7;
+}

Reply via email to