[llvm] r300085 - [InstCombine] In SimplifyMultipleUseDemandedBits, use a switch instead of cascaded ifs on opcode. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 11:25:26 PDT 2017


Author: ctopper
Date: Wed Apr 12 13:25:25 2017
New Revision: 300085

URL: http://llvm.org/viewvc/llvm-project?rev=300085&view=rev
Log:
[InstCombine] In SimplifyMultipleUseDemandedBits, use a switch instead of cascaded ifs on opcode. NFC

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

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=300085&r1=300084&r2=300085&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Wed Apr 12 13:25:25 2017
@@ -766,7 +766,8 @@ Value *InstCombiner::SimplifyMultipleUse
   // context, we can at least compute the knownzero/knownone bits, and we can
   // do simplifications that apply to *just* the one user if we know that
   // this instruction has a simpler value in that context.
-  if (I->getOpcode() == Instruction::And) {
+  switch (I->getOpcode()) {
+  case Instruction::And:
     // If either the LHS or the RHS are Zero, the result is zero.
     computeKnownBits(I->getOperand(1), RHSKnownZero, RHSKnownOne, Depth + 1,
                      CxtI);
@@ -787,7 +788,9 @@ Value *InstCombiner::SimplifyMultipleUse
     if ((DemandedMask & (RHSKnownZero|LHSKnownZero)) == DemandedMask)
       return Constant::getNullValue(ITy);
 
-  } else if (I->getOpcode() == Instruction::Or) {
+    break;
+
+  case Instruction::Or:
     // We can simplify (X|Y) -> X or Y in the user's context if we know that
     // only bits from X or Y are demanded.
 
@@ -815,7 +818,10 @@ Value *InstCombiner::SimplifyMultipleUse
     if ((DemandedMask & (~LHSKnownZero) & RHSKnownOne) ==
         (DemandedMask & (~LHSKnownZero)))
       return I->getOperand(1);
-  } else if (I->getOpcode() == Instruction::Xor) {
+
+    break;
+
+  case Instruction::Xor:
     // We can simplify (X^Y) -> X or Y in the user's context if we know that
     // only bits from X or Y are demanded.
 
@@ -830,6 +836,8 @@ Value *InstCombiner::SimplifyMultipleUse
       return I->getOperand(0);
     if ((DemandedMask & LHSKnownZero) == DemandedMask)
       return I->getOperand(1);
+
+    break;
   }
 
   // Compute the KnownZero/KnownOne bits to simplify things downstream.




More information about the llvm-commits mailing list