This amends the fix for PR100053 where I failed to amend all edge
tests in dominated_by_p_w_unex.
2021-05-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/100566
* tree-ssa-sccvn.c (dominated_by_p_w_unex): Properly handle
allow_back for all edge queries.
* gcc.dg/torture/pr100566.c: New testcase.
(cherry picked from commit
097fde5e7514e909f2e8472be2e008d0cab2260d)
--- /dev/null
+/* { dg-do run } */
+
+volatile int s, c;
+
+__attribute__((noipa)) void
+foo (void)
+{
+ if (c++ > 1)
+ __builtin_abort ();
+}
+
+__attribute__((noipa)) int
+bar (void)
+{
+ int i = 0, j = s;
+ if (j == 0)
+ goto lab;
+ for (i = 0; i < j; i++)
+ {
+ lab:
+ foo ();
+ if (!j)
+ goto lab;
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ s = 1;
+ bar ();
+ if (c != 1)
+ __builtin_abort ();
+ return 0;
+}
/* Iterate to the single executable bb2 successor. */
edge succe = NULL;
FOR_EACH_EDGE (e, ei, bb2->succs)
- if (e->flags & EDGE_EXECUTABLE)
+ if ((e->flags & EDGE_EXECUTABLE)
+ || (!allow_back && (e->flags & EDGE_DFS_BACK)))
{
if (succe)
{
{
FOR_EACH_EDGE (e, ei, succe->dest->preds)
if (e != succe
- && (e->flags & EDGE_EXECUTABLE))
+ && ((e->flags & EDGE_EXECUTABLE)
+ || (!allow_back && (e->flags & EDGE_DFS_BACK))))
{
succe = NULL;
break;