PATCH to fix infinite loop in CSE
Mark Mitchell
mark@codesourcery.com
Wed Oct 20 20:42:00 GMT 1999
If we had something like this:
BB1 <-
| |
BB2 |
| |
->BB3 --
| |
--BB4
We could loop forever in CSE. When we fall off BB4, we return to
BB3. We realize that we've already done BB3, so we want to skip it.
But, we call cse_end_of_basic_block, which cleverly thinks to follow
branches, and points us all the way back to the beginning of BB2.
That might not be exactly the right picture, but that's the idea.
I checked in the following fix.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
Wed Oct 20 20:41:46 1999 Mark Mitchell <mark@codesourcery.com>
* cse.c (cse_end_of_basic_block): Don't return the end of a basic
block reached by a branch if we're not going to actually process
this block.
Index: cse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cse.c,v
retrieving revision 1.98
diff -c -p -r1.98 cse.c
*** cse.c 1999/10/18 23:05:03 1.98
--- cse.c 1999/10/21 03:32:42
*************** cse_end_of_basic_block (insn, data, foll
*** 8442,8447 ****
--- 8442,8456 ----
path_size--;
}
+ /* If the first instruction is marked with QImode, that means we've
+ already processed this block. Our caller will look at DATA->LAST
+ to figure out where to go next. We want to return the next block
+ in the instruction stream, not some branched-to block somewhere
+ else. We accomplish this by pretending our called forbid us to
+ follow jumps, or skip blocks. */
+ if (GET_MODE (insn) == QImode)
+ follow_jumps = skip_blocks = 0;
+
/* Scan to end of this basic block. */
while (p && GET_CODE (p) != CODE_LABEL)
{
More information about the Gcc-patches
mailing list