From: Sanjay Patel Date: Thu, 7 Jul 2016 15:28:17 +0000 (+0000) Subject: save type in local var; NFCI X-Git-Tag: android-x86-7.1-r4~30676 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=849253f399857d4d642dc70955370b94f45d81ed;p=android-x86%2Fexternal-llvm.git save type in local var; NFCI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274760 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index db4ef6ec22d..d7eed790e2a 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -913,12 +913,13 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { Value *CondVal = SI.getCondition(); Value *TrueVal = SI.getTrueValue(); Value *FalseVal = SI.getFalseValue(); + Type *SelType = SI.getType(); if (Value *V = SimplifySelectInst(CondVal, TrueVal, FalseVal, DL, TLI, DT, AC)) return replaceInstUsesWith(SI, V); - if (SI.getType()->getScalarType()->isIntegerTy(1) && + if (SelType->getScalarType()->isIntegerTy(1) && TrueVal->getType() == CondVal->getType()) { if (match(TrueVal, m_One())) { // Change: A = select B, true, C --> A = or B, C @@ -960,25 +961,25 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { // select i1 %c, <2 x i8> <1, 1>, <2 x i8> <0, 0> // because that may need 3 instructions to splat the condition value: // extend, insertelement, shufflevector. - if (CondVal->getType()->isVectorTy() == SI.getType()->isVectorTy()) { + if (CondVal->getType()->isVectorTy() == SelType->isVectorTy()) { // select C, 1, 0 -> zext C to int if (match(TrueVal, m_One()) && match(FalseVal, m_Zero())) - return new ZExtInst(CondVal, SI.getType()); + return new ZExtInst(CondVal, SelType); // select C, -1, 0 -> sext C to int if (match(TrueVal, m_AllOnes()) && match(FalseVal, m_Zero())) - return new SExtInst(CondVal, SI.getType()); + return new SExtInst(CondVal, SelType); // select C, 0, 1 -> zext !C to int if (match(TrueVal, m_Zero()) && match(FalseVal, m_One())) { Value *NotCond = Builder->CreateNot(CondVal, "not." + CondVal->getName()); - return new ZExtInst(NotCond, SI.getType()); + return new ZExtInst(NotCond, SelType); } // select C, 0, -1 -> sext !C to int if (match(TrueVal, m_Zero()) && match(FalseVal, m_AllOnes())) { Value *NotCond = Builder->CreateNot(CondVal, "not." + CondVal->getName()); - return new SExtInst(NotCond, SI.getType()); + return new SExtInst(NotCond, SelType); } } @@ -1095,7 +1096,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { return IV; // See if we can fold the select into one of our operands. - if (SI.getType()->isIntOrIntVectorTy() || SI.getType()->isFPOrFPVectorTy()) { + if (SelType->isIntOrIntVectorTy() || SelType->isFPOrFPVectorTy()) { if (Instruction *FoldI = FoldSelectIntoOp(SI, TrueVal, FalseVal)) return FoldI; @@ -1107,7 +1108,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (SelectPatternResult::isMinOrMax(SPF)) { // Canonicalize so that type casts are outside select patterns. if (LHS->getType()->getPrimitiveSizeInBits() != - SI.getType()->getPrimitiveSizeInBits()) { + SelType->getPrimitiveSizeInBits()) { CmpInst::Predicate Pred = getCmpPredicateForMinMax(SPF, SPR.Ordered); Value *Cmp; @@ -1122,7 +1123,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { Value *NewSI = Builder->CreateCast(CastOp, Builder->CreateSelect(Cmp, LHS, RHS), - SI.getType()); + SelType); return replaceInstUsesWith(SI, NewSI); } } @@ -1229,7 +1230,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { return &SI; } - if (VectorType* VecTy = dyn_cast(SI.getType())) { + if (VectorType* VecTy = dyn_cast(SelType)) { unsigned VWidth = VecTy->getNumElements(); APInt UndefElts(VWidth, 0); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));