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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297968
91177308-0d34-0410-b5e6-
96231b3b80d8
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;
liveins: %w0, %w1
%0(s32) = COPY %w0
- %1(s32) = G_CONSTANT 1
+ %1(s32) = G_CONSTANT i32 1
%2(s32) = G_ADD %0, %1
...
successors: %bb.1
%0(s32) = COPY %w0
- %1(s32) = G_CONSTANT 1
+ %1(s32) = G_CONSTANT i32 1
G_BR %bb.1
bb.1: