https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66790
--- Comment #28 from Bernd Schmidt <bernds at gcc dot gnu.org> --- (In reply to Pierre-Marie de Rodat from comment #27) > (In reply to Bernd Schmidt from comment #14) > > It looks like your "visited" bit tries to avoid that, but I don't > > think this works. > (In reply to Paolo Bonzini from comment #19) > > There's no code in GCC for must-initialized. Pierre's patch gets it right > > (except that I'm not sure about the comment at line 2033). > The "visited" bit I introduced is used to fake an "all bits set" > initialization. The confluence_n method is meant to do: > > IN(dest) = OUT(src_0) AND OUT(src_1) AND ... > > ... by small increments of: > > IN(dest) := IN(dest) AND OUT(src_i) > > When it is executed for the first time, IN(dest) is all-zeros, so we do > a copy because "a AND all_ones = a". Then we can do regular AND later > on. In order to get rid of this "visited" bit, I guess we could instead > pretend that IN/OUT sets are set of never-or-may-initialized registers, > but this complicates other parts of the code, so... I know this is what it's trying to do, but when I experimented with it that wasn't working, due to the problem I described. > If I understand correctly, the BB_LAST_CHANGE_AGE mechanism in df-core.h > makes sure computations comply with this dependency (c. before b., b. > before a.). So at the point the confluence_n function for the 3 -> 3 > edges is called for the first time, both IN(3) and OUT(3) can be not > all-zeros. It is sufficient for OUT(3) to be all-zeros. And I don't think the LAST_CHANGE_AGE mechanism does anything to prevent it. Please try it out. I think you have to initialize your bitmaps correctly rather than rely on "visited". I applied your patch and compiled the following with a breakpoint on df_mir_confluence_n: int foo (int n) { int sum = 0; for (int i = 0; i < n; i++) sum += i; return sum; } and when it reaches the loop: Breakpoint 5, df_mir_confluence_n (e=<edge 0x7ffff07352d8 (4 -> 4)>) at ../../trunk/gcc/df-problems.c:2040 (gdb) p debug_bitmap (op1) first = 0x24bf418 current = 0x24bf418 indx = 0 0x24bf418 next = (nil) prev = (nil) indx = 0 bits = { 0 1 2 4 5 7 17 21 22 23 24 25 26 27 28 37 38 } $2 = void (gdb) p debug_bitmap (op2) first = (nil) current = (nil) indx = 0 and (gdb) p bb_info->visited $5 = true because the edge 3->4 was seen first. > (In reply to Bernd Schmidt from comment #14) > > I do have to say that I am still uncomfortable with changing RRE to I did not write this.