summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAmara Emerson <aemerson@apple.com>2019-06-09 07:31:25 +0000
committerAmara Emerson <aemerson@apple.com>2019-06-09 07:31:25 +0000
commit0d20969deaf9cf3060f2cf641eb2870c5634d1b2 (patch)
treed4adaa041742a088a2a0c9e9c96f8a3c1a45edf2 /llvm/lib
parent2ba0e2518b96392f9f2352d10fc5a27bbbc92fa9 (diff)
downloadbcm5719-llvm-0d20969deaf9cf3060f2cf641eb2870c5634d1b2.tar.gz
bcm5719-llvm-0d20969deaf9cf3060f2cf641eb2870c5634d1b2.zip
[AArch64][GlobalISel] Select immediate forms of cmp instructions.
A simple re-use of the immediate operand matcher and renderer functions. rdar://43795178 llvm-svn: 362896
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
index df9fd739f57..cd3ca7cf37d 100644
--- a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
@@ -1858,6 +1858,11 @@ bool AArch64InstructionSelector::select(MachineInstr &I,
return false;
}
+ // Try to match immediate forms.
+ auto ImmFns = selectArithImmed(I.getOperand(3));
+ if (ImmFns)
+ CmpOpc = CmpOpc == AArch64::SUBSWrr ? AArch64::SUBSWri : AArch64::SUBSXri;
+
// CSINC increments the result by one when the condition code is false.
// Therefore, we have to invert the predicate to get an increment by 1 when
// the predicate is true.
@@ -1865,10 +1870,17 @@ bool AArch64InstructionSelector::select(MachineInstr &I,
changeICMPPredToAArch64CC(CmpInst::getInversePredicate(
(CmpInst::Predicate)I.getOperand(1).getPredicate()));
- MachineInstr &CmpMI = *BuildMI(MBB, I, I.getDebugLoc(), TII.get(CmpOpc))
- .addDef(ZReg)
- .addUse(I.getOperand(2).getReg())
- .addUse(I.getOperand(3).getReg());
+ auto CmpMI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(CmpOpc))
+ .addDef(ZReg)
+ .addUse(I.getOperand(2).getReg());
+
+ // If we matched a valid constant immediate, add those operands.
+ if (ImmFns) {
+ for (auto &RenderFn : *ImmFns)
+ RenderFn(CmpMI);
+ } else {
+ CmpMI.addUse(I.getOperand(3).getReg());
+ }
MachineInstr &CSetMI =
*BuildMI(MBB, I, I.getDebugLoc(), TII.get(AArch64::CSINCWr))
@@ -1877,7 +1889,7 @@ bool AArch64InstructionSelector::select(MachineInstr &I,
.addUse(AArch64::WZR)
.addImm(invCC);
- constrainSelectedInstRegOperands(CmpMI, TII, TRI, RBI);
+ constrainSelectedInstRegOperands(*CmpMI, TII, TRI, RBI);
constrainSelectedInstRegOperands(CSetMI, TII, TRI, RBI);
I.eraseFromParent();
OpenPOWER on IntegriCloud