When a ptest is used to set flags from the output of rdffr, the ptest
can be eliminated, using a flags-setting rdffrs instead.
Additionally, check that nothing consumes flags between rdffr and ptest;
this case appears to have been missed previously.
- There is no unpredicated RDFFRS instruction.
- If substituting RDFFR_PP, require that the mask argument of the PTEST matches that of the RDFFR_PP.
- Move some precondition code up inside optimizePTestInstr, so that it covers the new code paths for RDFFR which return earlier.
- Only consider RDFFR, PTEST in same basic block.
- Check for other flag setting instructions between the two, abort if found.
- Drop an old TODO comment about removing dead PTEST instructions.
RDFFR_P to follow in later patch.
I have no proof on this so feel free to ignore if you disagree.
Hoisting the Pred->getParent() != PTest->getParent() part offers a faster route to termination so I'm good with that.
However, I feel iterating across the BB's instructions may not and so that part might be better to keep until after we've decided Mask and Pred are interesting.