From ef29e7284b355e5ca8931e73bf6312d33a549c23 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 24 Feb 2017 21:21:38 +0000 Subject: GlobalISel: check for CImm rather than Imm on G_CONSTANTs. All G_CONSTANTS created by the MachineIRBuilder have an operand of type CImm (i.e. a ConstantInt), so that's what the selector needs to look for. llvm-svn: 296176 --- llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp') diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp index a38ff00ed41..c1e4a8661a2 100644 --- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -20,6 +20,7 @@ #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/TargetPassConfig.h" +#include "llvm/IR/Constants.h" #include "llvm/IR/Function.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -187,8 +188,10 @@ bool InstructionSelector::isOperandImmEqual( 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; + assert(Def->getOperand(1).isCImm() && + "G_CONSTANT values must be constants"); + const ConstantInt &Imm = *Def->getOperand(1).getCImm(); + return Imm.getBitWidth() <= 64 && Imm.getSExtValue() == Value; } return false; -- cgit v1.2.3