Comment 2 for bug 851258

Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

The problem is introduced in the "fre1" tree pass (currently number 028).

I see three ways to fix this:

1. Fix "fre1" to not do it where the backend has a suitable compare insn. I suspect this is not going to happen since the pass probably does 'see' that much context.

2. Add another tree pass (in a similar vein to the widening-multiply passes, and assuming there isn't already one that should do this) that searches for test-and-branch cases and emits the whole thing as a single tree-code. Then teach expand to DTRT.

3. Get the "combine" pass to fix it at the RTL stage. However, I think combine currently refuses to do anything with pseudos that are used in more than one place, so maybe that's not going to happen.

Clearly, the optimization is only useful in the case where *both* the value being tested *and* the test result live on past the branch. In the case where the either value is dead the optimization should be harmless (combine would have dealt with them anyway, and/or register pressure would not be an issue).