[Bug target/40416] unnecessary register spill

carrot at google dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 15 02:32:00 GMT 2009



------- Comment #4 from carrot at google dot com  2009-06-15 02:32 -------
In the source code, only two extra variables next_runs and next_alpha need to
be preserved through the while loop.

But in the gcc generated code, three variables are kept through the first loop.
They are next_alpha, original runs and original x. The expression (next_runs =
runs + x) is moved after the loop. This caused an extra var through the loop
and resulted in register spilling.

The expression move is occurred in tree-ssa-sink pass. Daniel Berlin has
confirmed it is a bug in this pass.

******** From Daniel **************
This looks like a bug, i think i know what causes it.
When I wrote this pass, i forgot to make this check:

 /* It doesn't make sense to move to a dominator that post-dominates
        frombb, because it means we've just moved it into a path that always
        executes if frombb executes, instead of reducing the number of
        executions .  */

     if (dominated_by_p (CDI_POST_DOMINATORS, frombb, commondom))

happen regardless of whether it is a single use statement or not.
So it will sink single use statements even if it's just moving them to
places that aren't executed less frequently.

Add that check (changing commondom to sinkbb) and it should stop moving it.
*********** End From Daniel ****************

I will send the patch later.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40416



More information about the Gcc-bugs mailing list