summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2019-03-28 09:09:27 +0000
committerDiana Picus <diana.picus@linaro.org>2019-03-28 09:09:27 +0000
commit4d512df30035c54a81b2e67d80debbc09b003afb (patch)
tree600a0c093400c88d93c2210528c7506dc235d74c /llvm/lib
parentc2423fe6899aad89fe0ac2aa4b873cb79ec15bd0 (diff)
downloadbcm5719-llvm-4d512df30035c54a81b2e67d80debbc09b003afb.tar.gz
bcm5719-llvm-4d512df30035c54a81b2e67d80debbc09b003afb.zip
[ARM GlobalISel] Fix selection of G_SELECT
G_SELECT uses a 1-bit scalar for the condition, and is currently implemented with a plain CMPri against 0. This means that values such as 0x1110 are interpreted as true, when instead the higher bits should be treated as undefined and therefore ignored. Replace the CMPri with a TSTri against 0x1, which performs an implicit AND, yielding the expected result. llvm-svn: 357153
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/ARM/ARMInstructionSelector.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp
index a9f1f6bbc22..d0b63d676da 100644
--- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp
+++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp
@@ -111,7 +111,6 @@ private:
unsigned MOVCCi;
// Used for G_SELECT
- unsigned CMPri;
unsigned MOVCCr;
unsigned TSTri;
@@ -319,7 +318,6 @@ ARMInstructionSelector::OpcodeCache::OpcodeCache(const ARMSubtarget &STI) {
STORE_OPCODE(MOVi, MOVi);
STORE_OPCODE(MOVCCi, MOVCCi);
- STORE_OPCODE(CMPri, CMPri);
STORE_OPCODE(MOVCCr, MOVCCr);
STORE_OPCODE(TSTri, TSTri);
@@ -767,13 +765,13 @@ bool ARMInstructionSelector::selectSelect(MachineInstrBuilder &MIB,
auto InsertBefore = std::next(MIB->getIterator());
auto &DbgLoc = MIB->getDebugLoc();
- // Compare the condition to 0.
+ // Compare the condition to 1.
auto CondReg = MIB->getOperand(1).getReg();
assert(validReg(MRI, CondReg, 1, ARM::GPRRegBankID) &&
"Unsupported types for select operation");
- auto CmpI = BuildMI(MBB, InsertBefore, DbgLoc, TII.get(Opcodes.CMPri))
+ auto CmpI = BuildMI(MBB, InsertBefore, DbgLoc, TII.get(Opcodes.TSTri))
.addUse(CondReg)
- .addImm(0)
+ .addImm(1)
.add(predOps(ARMCC::AL));
if (!constrainSelectedInstRegOperands(*CmpI, TII, TRI, RBI))
return false;
OpenPOWER on IntegriCloud