Skip to content

Commit 4158652

Browse files
committed
use local variables; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253356 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e656ca2 commit 4158652

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/Transforms/InstCombine/InstCombineCasts.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
469469

470470
// Canonicalize trunc x to i1 -> (icmp ne (and x, 1), 0), likewise for vector.
471471
if (DestTy->getScalarSizeInBits() == 1) {
472-
Constant *One = ConstantInt::get(Src->getType(), 1);
472+
Constant *One = ConstantInt::get(SrcTy, 1);
473473
Src = Builder->CreateAnd(Src, One);
474474
Value *Zero = Constant::getNullValue(Src->getType());
475475
return new ICmpInst(ICmpInst::ICMP_NE, Src, Zero);
@@ -488,14 +488,14 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
488488
// If the shift amount is larger than the size of A, then the result is
489489
// known to be zero because all the input bits got shifted out.
490490
if (Cst->getZExtValue() >= ASize)
491-
return ReplaceInstUsesWith(CI, Constant::getNullValue(CI.getType()));
491+
return ReplaceInstUsesWith(CI, Constant::getNullValue(DestTy));
492492

493493
// Since we're doing an lshr and a zero extend, and know that the shift
494494
// amount is smaller than ASize, it is always safe to do the shift in A's
495495
// type, then zero extend or truncate to the result.
496496
Value *Shift = Builder->CreateLShr(A, Cst->getZExtValue());
497497
Shift->takeName(Src);
498-
return CastInst::CreateIntegerCast(Shift, CI.getType(), false);
498+
return CastInst::CreateIntegerCast(Shift, DestTy, false);
499499
}
500500

501501
// Transform trunc(lshr (sext A), Cst) to ashr A, Cst to eliminate type
@@ -520,12 +520,12 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
520520

521521
// Transform "trunc (and X, cst)" -> "and (trunc X), cst" so long as the dest
522522
// type isn't non-native.
523-
if (Src->hasOneUse() && isa<IntegerType>(Src->getType()) &&
524-
ShouldChangeType(Src->getType(), CI.getType()) &&
523+
if (Src->hasOneUse() && isa<IntegerType>(SrcTy) &&
524+
ShouldChangeType(SrcTy, DestTy) &&
525525
match(Src, m_And(m_Value(A), m_ConstantInt(Cst)))) {
526-
Value *NewTrunc = Builder->CreateTrunc(A, CI.getType(), A->getName()+".tr");
526+
Value *NewTrunc = Builder->CreateTrunc(A, DestTy, A->getName() + ".tr");
527527
return BinaryOperator::CreateAnd(NewTrunc,
528-
ConstantExpr::getTrunc(Cst, CI.getType()));
528+
ConstantExpr::getTrunc(Cst, DestTy));
529529
}
530530

531531
return nullptr;

0 commit comments

Comments
 (0)