Skip to content

Commit e918127

Browse files
committed
[InstSimplify] Avoid ConstantExpr::getIntegerCast() (NFCI)
This always works on a constant integer or integer splat, so the constant fold here should always succeed.
1 parent d9f36c4 commit e918127

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,8 @@ static Value *simplifySubInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
895895
// Variations on GEP(base, I, ...) - GEP(base, i, ...) -> GEP(null, I-i, ...).
896896
if (match(Op0, m_PtrToInt(m_Value(X))) && match(Op1, m_PtrToInt(m_Value(Y))))
897897
if (Constant *Result = computePointerDifference(Q.DL, X, Y))
898-
return ConstantExpr::getIntegerCast(Result, Op0->getType(), true);
898+
return ConstantFoldIntegerCast(Result, Op0->getType(), /*IsSigned*/ true,
899+
Q.DL);
899900

900901
// i1 sub -> xor.
901902
if (MaxRecurse && Op0->getType()->isIntOrIntVectorTy(1))

0 commit comments

Comments
 (0)