This is an archive of the discontinued LLVM Phabricator instance.

[EarlyIfConversion] Avoid producing selects with identical operands
ClosedPublic

Authored by jroelofs on Apr 28 2021, 6:39 PM.

Details

Summary

This extends the early-ifcvt pass to avoid a few more cases where the resulting select instructions would have matching operands. Additionally, we now use TII to determine "sameness" of the operands so that as TII gets smarter, so too will ifcvt.

The attached test case was bugpoint-reduced down from CINT2000/252.eon in the test-suite. See: https://clang.godbolt.org/z/WvnrcrGEn

Diff Detail

Event Timeline

jroelofs created this revision.Apr 28 2021, 6:39 PM
jroelofs requested review of this revision.Apr 28 2021, 6:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2021, 6:39 PM

Please add a testcase

jroelofs updated this revision to Diff 341382.Apr 28 2021, 6:41 PM

Please add a testcase

oops. forgot to git-add. thanks for the reminder!

jroelofs edited the summary of this revision. (Show Details)Apr 28 2021, 6:43 PM
thegameg added inline comments.Apr 28 2021, 6:59 PM
llvm/test/CodeGen/AArch64/early-ifcvt-same-value.mir
3

mcpu needed?

jroelofs added inline comments.Apr 28 2021, 7:04 PM
llvm/test/CodeGen/AArch64/early-ifcvt-same-value.mir
3

Yes, otherwise the if-conversion doesn't fire.

jroelofs added inline comments.Apr 28 2021, 7:08 PM
llvm/test/CodeGen/AArch64/early-ifcvt-same-value.mir
3

erm, you're right. I must have needed that before I added -stress-early-ifcvt

jroelofs updated this revision to Diff 341533.Apr 29 2021, 8:41 AM
thegameg accepted this revision.Apr 29 2021, 9:24 AM

LGTM, thanks! In general, I like this direction more than the TII::optimizeSelect one.

This revision is now accepted and ready to land.Apr 29 2021, 9:24 AM
dmgreen added inline comments.Apr 29 2021, 10:29 AM
llvm/lib/CodeGen/EarlyIfConversion.cpp
569

Does what you mentioned in D46278 apply here too? If the MachineInstr's have multiple defs, like a LDRpre or LDP, does it need to be careful which operand it is defined in and whether they match?

jroelofs updated this revision to Diff 341606.Apr 29 2021, 12:23 PM

Handle instructions with multiple defs.

dmgreen added inline comments.Apr 30 2021, 3:41 AM
llvm/lib/CodeGen/EarlyIfConversion.cpp
560

Can this use MachineInstr::findRegisterDefOperandIdx?

jroelofs updated this revision to Diff 341949.Apr 30 2021, 9:53 AM
dmgreen accepted this revision.Apr 30 2021, 12:28 PM

Thanks. Sounds good to me too.

This revision was landed with ongoing or failed builds.Apr 30 2021, 2:43 PM
This revision was automatically updated to reflect the committed changes.