[llvm] r274760 - save type in local var; NFCI

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 08:28:18 PDT 2016


Author: spatel
Date: Thu Jul  7 10:28:17 2016
New Revision: 274760

URL: http://llvm.org/viewvc/llvm-project?rev=274760&view=rev
Log:
save type in local var; NFCI

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=274760&r1=274759&r2=274760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Thu Jul  7 10:28:17 2016
@@ -913,12 +913,13 @@ Instruction *InstCombiner::visitSelectIn
   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::visitSelectIn
   // 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::visitSelectIn
       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::visitSelectIn
     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::visitSelectIn
 
         Value *NewSI = Builder->CreateCast(CastOp,
                                            Builder->CreateSelect(Cmp, LHS, RHS),
-                                           SI.getType());
+                                           SelType);
         return replaceInstUsesWith(SI, NewSI);
       }
     }
@@ -1229,7 +1230,7 @@ Instruction *InstCombiner::visitSelectIn
     return &SI;
   }
 
-  if (VectorType* VecTy = dyn_cast<VectorType>(SI.getType())) {
+  if (VectorType* VecTy = dyn_cast<VectorType>(SelType)) {
     unsigned VWidth = VecTy->getNumElements();
     APInt UndefElts(VWidth, 0);
     APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));




More information about the llvm-commits mailing list