This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Search backwards for CMP when combining into CBZ
ClosedPublic

Authored by dmgreen on Mar 13 2019, 12:44 PM.

Details

Summary

The constant island pass currently only looks at the instruction immediately before a branch for a CMP to fold into a CBZ/CBNZ. This extends it to search backwards for the instruction that defines CPSR. We need to ensure that the register is not overridden between the CMP and the branch.

The test cases are new, I have just shown the differences for clarity.

Diff Detail

Event Timeline

dmgreen created this revision.Mar 13 2019, 12:44 PM
dmgreen updated this revision to Diff 190585.Mar 14 2019, 3:38 AM
dmgreen edited the summary of this revision. (Show Details)

Now with some mir tests.

samparker added inline comments.Mar 14 2019, 3:49 AM
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
1931

Do we need to still check this? I'm assuming we can't have a tCMPi8 with a high reg?

dmgreen marked 2 inline comments as done.Mar 14 2019, 5:43 AM
dmgreen added inline comments.
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
1931

Yeah, good point. It's only the two register CMP that can take higher registers. I'll removed it here.

dmgreen updated this revision to Diff 190606.Mar 14 2019, 5:44 AM
dmgreen marked an inline comment as done.

Removed isARMLowRegister check, reversed the condition of DestOffset - BrOffset, and added some Kill flag handling and tests.

This revision is now accepted and ready to land.Mar 14 2019, 8:55 AM
This revision was automatically updated to reflect the committed changes.