summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h5
-rw-r--r--llvm/test/CodeGen/ARM/GlobalISel/pr35375.ll12
2 files changed, 17 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
index 2704dc25c0e..8848274d22e 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
@@ -337,6 +337,11 @@ bool InstructionSelector::executeMatchTable(
<< InsnID << "]->getOperand(" << OpIdx
<< "), Value=" << Value << ")\n");
assert(State.MIs[InsnID] != nullptr && "Used insn before defined");
+
+ // isOperandImmEqual() will sign-extend to 64-bits, so should we.
+ LLT Ty = MRI.getType(State.MIs[InsnID]->getOperand(OpIdx).getReg());
+ Value = SignExtend64(Value, Ty.getSizeInBits());
+
if (!isOperandImmEqual(State.MIs[InsnID]->getOperand(OpIdx), Value,
MRI)) {
if (handleReject() == RejectAndGiveUp)
diff --git a/llvm/test/CodeGen/ARM/GlobalISel/pr35375.ll b/llvm/test/CodeGen/ARM/GlobalISel/pr35375.ll
new file mode 100644
index 00000000000..ebef54542bc
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/GlobalISel/pr35375.ll
@@ -0,0 +1,12 @@
+; RUN: llc -O0 -mtriple armv7-- -stop-before=expand-isel-pseudos < %s
+; RUN: llc -O0 -mtriple armv7-- -stop-before=expand-isel-pseudos -global-isel < %s
+
+; CHECK: PKHBT
+
+define arm_aapcscc i32 @pkh(i32 %x, i32 %y) {
+ %andx = and i32 %x, 65535
+ %shl = shl i32 %y, 1
+ %andy = and i32 %shl, 4294901760 ; same as -65536
+ %or = or i32 %andx, %andy
+ ret i32 %or
+}
OpenPOWER on IntegriCloud