Add support for selecting FCMPSri and FCMPDri when comparing against 0.0, and factor out opcode selection for G_FCMP into its own function.
Add a test to show that we don't do this with other immediates.
Paths
| Differential D62539
[AArch64][GlobalISel] Select FCMPSri/FCMPDri when comparing against 0.0 ClosedPublic Authored by paquette on May 28 2019, 11:25 AM.
Details Summary Add support for selecting FCMPSri and FCMPDri when comparing against 0.0, and factor out opcode selection for G_FCMP into its own function. Add a test to show that we don't do this with other immediates.
Diff Detail Event TimelineHerald added subscribers: Petar.Avramovic, hiraditya, kristof.beyls and 2 others. · View Herald Transcript Comment Actions LGTM. Can make a small change to make things a bit more concise but not very important.
This revision is now accepted and ready to land.May 28 2019, 1:48 PM Closed by commit rL361888: [AArch64][GlobalISel] Select FCMPSri/FCMPDri when comparing against 0.0 (authored by paquette). · Explain WhyMay 28 2019, 3:50 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 201729 llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/select-fcmp.mir
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Not a big deal, but you can turn this logic into a small lookup table, like:
unsigned OpSize = MRI.getType(I.getOperand(2).getReg()).getSizeInBits(); unsigned CmpOpcTbl[2][2] = {{FCmpSri, FCmpDri}, {FCmpSrr, FCmpDrr}}; return CmpOpcTbl[ShouldUseImm][OpSize == 64];