#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"
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;
liveins: %w0
%0(s32) = COPY %w0
- %1(s32) = G_CONSTANT -1
+ %1(s32) = G_CONSTANT i64 -1
%2(s32) = G_XOR %0, %1
...
liveins: %x0
%0(s64) = COPY %x0
- %1(s64) = G_CONSTANT -1
+ %1(s64) = G_CONSTANT i64 -1
%2(s64) = G_XOR %0, %1
...
bb.0:
liveins: %w0, %w1
successors: %bb.1
- %1(s32) = G_CONSTANT -1
+ %1(s32) = G_CONSTANT i64 -1
G_BR %bb.1
bb.1:
%0(s32) = COPY %w0
%2(s32) = G_XOR %0, %1
...
-