diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp | 17 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp | 5 |
2 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp index 0f7a254075a..a38ff00ed41 100644 --- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -176,3 +176,20 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) { // FIXME: Should we accurately track changes? return true; } + +bool InstructionSelector::isOperandImmEqual( + const MachineOperand &MO, int64_t Value, + const MachineRegisterInfo &MRI) const { + // TODO: We should also test isImm() and isCImm() too but this isn't required + // until a DAGCombine equivalent is implemented. + + if (MO.isReg()) { + MachineInstr *Def = MRI.getVRegDef(MO.getReg()); + if (Def->getOpcode() != TargetOpcode::G_CONSTANT) + return false; + assert(Def->getOperand(1).isImm() && "G_CONSTANT values must be constants"); + return Def->getOperand(1).getImm() == Value; + } + + return false; +} diff --git a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp index f83c7f0e6cc..1656b5c6efc 100644 --- a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp @@ -634,9 +634,12 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const { // FIXME: Is going through int64_t always correct? ImmOp.ChangeToImmediate( ImmOp.getFPImm()->getValueAPF().bitcastToAPInt().getZExtValue()); - } else { + } else if (I.getOperand(1).isCImm()) { uint64_t Val = I.getOperand(1).getCImm()->getZExtValue(); I.getOperand(1).ChangeToImmediate(Val); + } else if (I.getOperand(1).isImm()) { + uint64_t Val = I.getOperand(1).getImm(); + I.getOperand(1).ChangeToImmediate(Val); } constrainSelectedInstRegOperands(I, TII, TRI, RBI); |