Skip to content

Commit aef0496

Browse files
AlexeyMerzlyakovJeffreyALaw
authored andcommitted
[PR rtl-optimization/119099] Avoid infinite loop in ext-dce.
This fixes the ping-ponging of live sets in ext-dce which is left unresolved can lead to infinite loops in the ext-dce pass as seen by the P1 regression 119099. At its core instead of replacing the livein set with the just recomputed data, we IOR in the just recomputed data to the existing livein set. That ensures the existing livein set never shrinks. Bootstrapped and regression tested on x86. I've also thrown this into my tester to verify it across multiple targets and that we aren't regressing the (limited) tests we have in place for ext-dce's optimization behavior. While it's a generic patch, I'll wait for the RISC-V tester to run is course before committing. PR rtl-optimization/119099 gcc/ * ext-dce.cc (ext_dce_rd_transfer_n): Do not allow the livein set to shrink. gcc/testsuite/ * gcc.dg/torture/pr119099.c: New test. Co-authored-by: Jeff Law <[email protected]>
1 parent ac8a70d commit aef0496

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

gcc/ext-dce.cc

+3-10
Original file line numberDiff line numberDiff line change
@@ -1089,16 +1089,9 @@ ext_dce_rd_transfer_n (int bb_index)
10891089

10901090
ext_dce_process_bb (bb);
10911091

1092-
/* We may have narrowed the set of live objects at the start
1093-
of this block. If so, update the bitmaps and indicate to
1094-
the generic dataflow code that something changed. */
1095-
if (!bitmap_equal_p (&livein[bb_index], livenow))
1096-
{
1097-
bitmap_copy (&livein[bb_index], livenow);
1098-
return true;
1099-
}
1100-
1101-
return false;
1092+
/* We only allow widening the set of objects live at the start
1093+
of a block. Otherwise we run the risk of not converging. */
1094+
return bitmap_ior_into (&livein[bb_index], livenow);
11021095
}
11031096

11041097
/* Dummy function for the df_simple_dataflow API. */
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* { dg-do compile } */
2+
3+
int a, b;
4+
5+
void func2(short);
6+
7+
void func1() {
8+
while (1) {
9+
int loc = 8;
10+
while (1) {
11+
func2(loc);
12+
if (a)
13+
loc = 3;
14+
else if (b)
15+
break;
16+
loc |= a;
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)