Skip to content

Commit e408f70

Browse files
committed
[LSR] Avoid use of ConstantExpr::getCast() (NFC)
Use the constant folding API instead, which must succeed as we're working on a ConstantInt.
1 parent 8f564e0 commit e408f70

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5546,10 +5546,12 @@ Value *LSRInstance::Expand(const LSRUse &LU, const LSRFixup &LF,
55465546
"a scale at the same time!");
55475547
Constant *C = ConstantInt::getSigned(SE.getEffectiveSCEVType(OpTy),
55485548
-(uint64_t)Offset);
5549-
if (C->getType() != OpTy)
5550-
C = ConstantExpr::getCast(CastInst::getCastOpcode(C, false,
5551-
OpTy, false),
5552-
C, OpTy);
5549+
if (C->getType() != OpTy) {
5550+
C = ConstantFoldCastOperand(
5551+
CastInst::getCastOpcode(C, false, OpTy, false), C, OpTy,
5552+
CI->getModule()->getDataLayout());
5553+
assert(C && "Cast of ConstantInt should have folded");
5554+
}
55535555

55545556
CI->setOperand(1, C);
55555557
}

0 commit comments

Comments
 (0)