This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Fix CPSR liveness in tMOVCCr_pseudo lowering.
ClosedPublic

Authored by efriedma on Nov 6 2018, 5:48 PM.

Details

Summary

The lowering was missing live-ins in certain cases, like a sequence of multiple tMOVCCr_pseudo instructions. This would lead to a verifier failure, and on pre-v6 Thumb CPSR would be incorrectly clobbered.

For reasons I don't completely understand, it's hard to get a sequence of multiple tMOVCCr_pseudo instructions; the issue only seems to show up with 64-bit comparisons where the result is zero-extended. I added some extra testcases in case that changes in the future. Probably some optimization opportunities here if anyone is interested. (@test_slt_not is the case that was getting miscompiled.)

The code to check the liveness of CPSR was stolen from X86ISelLowering.cpp; maybe it could be refactored into common helper, but I have no idea where to put it.

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma created this revision.Nov 6 2018, 5:48 PM
SjoerdMeijer accepted this revision.Nov 7 2018, 5:21 AM

Looks very reasonable to me.

test/CodeGen/ARM/wide-compares.ll
130 ↗(On Diff #172883)

My first impression of the tests was that they could benefit from a bit of a clean-up (stack offsets, register usage, asm comments, etc.). But looks like there are 2 schools of thoughts on this. One of them being that the output of the script is okay because it is explicit, shows everything, etc. So yeah, please ignore, whatever you think is appropriate.

This revision is now accepted and ready to land.Nov 7 2018, 5:21 AM
efriedma added inline comments.Nov 7 2018, 12:16 PM
test/CodeGen/ARM/wide-compares.ll
130 ↗(On Diff #172883)

The philosophy behind update_llc_test_checks.py is that the generated code for very small functions should change infrequently, and when it does change it's easy to update the CHECK lines by just calling update_llc_test_checks.py again.

This revision was automatically updated to reflect the committed changes.