This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Make ARMExpandPseudo add implicit uses for predicated instructions
ClosedPublic

Authored by efriedma on Jul 7 2017, 3:28 PM.

Details

Summary

Missing these could potentially screw up post-ra scheduling.

Issue found by inspection, so I don't have a real testcase. Included test just verifies the expected operands after expansion.

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma created this revision.Jul 7 2017, 3:28 PM
rovka added a subscriber: rovka.Jul 10 2017, 2:47 AM

Hi Eli,

I couldn't find an awful lot of tests for ARM pseudo expansion in particular, so I think it would be nice to add one. A MIR test checking each of the transformations that you touched in this patch would work fine.

I've been looking into this area myself recently and found it all a bit confusing. I have a few questions inline, sorry if they're a bit basic.

Thanks.

lib/Target/ARM/ARMExpandPseudoInsts.cpp
1081 ↗(On Diff #105717)

How exactly does this work? You're already passing the register from MI.getOperand(1) to BuildMI, which IIUC will mark it as a define. Why do you also need to make it implicit?

1135 ↗(On Diff #105717)

IIUC, MOVi16 is AI1, not AsI1. Doesn't that mean it shouldn't set any CC, so you don't need an implicit operand for it at all?

OK, I'll add a testcase.

lib/Target/ARM/ARMExpandPseudoInsts.cpp
1081 ↗(On Diff #105717)

We also need to mark it as a use (the instruction is predicated, so if the predicate is false, the value isn't modified).

It's an implicit use because it isn't encoded anywhere in the instruction.

1135 ↗(On Diff #105717)

It doesn't modify CPSR. It uses CPSR ("MI.getOperand(4)"). I'm not sure how that's relevant to this patch, though.

efriedma updated this revision to Diff 106109.Jul 11 2017, 3:51 PM
efriedma edited the summary of this revision. (Show Details)

Added testcases (didn't add a testcase for every single opcode, since there's a lot of them, but this should be enough to illustrate what's happening).

rovka added a comment.Jul 12 2017, 4:44 AM

Thanks for the test-case and the explanations.
LGTM but you should probably wait for someone more versed in these things to give the final approval.

lib/Target/ARM/ARMExpandPseudoInsts.cpp
1135 ↗(On Diff #105717)

Sorry, I don't know where I was going with that, the code looks perfectly fine.

test/CodeGen/ARM/expand-pseudos.mir
69 ↗(On Diff #106109)

If you want to move the checks closer to the code, you can use ; CHECK (instead of # CHECK).

olista01 accepted this revision.Sep 1 2017, 5:55 AM
olista01 added a subscriber: olista01.

This LGTM, but could you please commit the pass registration changes as a separate commit, as they are not really related to this change.

This revision is now accepted and ready to land.Sep 1 2017, 5:55 AM
This revision was automatically updated to reflect the committed changes.