[llvm] r297968 - [globalisel] Correct G_CONSTANT path of selectArithImmed()
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 11:04:50 PDT 2017
Author: dsanders
Date: Thu Mar 16 13:04:50 2017
New Revision: 297968
URL: http://llvm.org/viewvc/llvm-project?rev=297968&view=rev
Log:
[globalisel] Correct G_CONSTANT path of selectArithImmed()
Earlier stages of GlobalISel always use ConstantInt in G_CONSTANT so that's
what we should check for.
This fixes a crash introduced in r297782.
Modified:
llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-binop.mir
Modified: llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp?rev=297968&r1=297967&r2=297968&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp Thu Mar 16 13:04:50 2017
@@ -1246,7 +1246,10 @@ bool AArch64InstructionSelector::selectA
MachineInstr *Def = MRI.getVRegDef(Root.getReg());
if (Def->getOpcode() != TargetOpcode::G_CONSTANT)
return false;
- Immed = Def->getOperand(1).getImm();
+ MachineOperand &Op1 = Def->getOperand(1);
+ if (!Op1.isCImm() || Op1.getCImm()->getBitWidth() > 64)
+ return false;
+ Immed = Op1.getCImm()->getZExtValue();
} else
return false;
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-binop.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-binop.mir?rev=297968&r1=297967&r2=297968&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-binop.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-binop.mir Thu Mar 16 13:04:50 2017
@@ -137,7 +137,7 @@ body: |
liveins: %w0, %w1
%0(s32) = COPY %w0
- %1(s32) = G_CONSTANT 1
+ %1(s32) = G_CONSTANT i32 1
%2(s32) = G_ADD %0, %1
...
@@ -193,7 +193,7 @@ body: |
successors: %bb.1
%0(s32) = COPY %w0
- %1(s32) = G_CONSTANT 1
+ %1(s32) = G_CONSTANT i32 1
G_BR %bb.1
bb.1:
More information about the llvm-commits
mailing list