[llvm-branch-commits] [llvm-branch] r115648 - /llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp

Gabor Greif ggreif at gmail.com
Tue Oct 5 11:39:24 PDT 2010


Author: ggreif
Date: Tue Oct  5 13:39:24 2010
New Revision: 115648

URL: http://llvm.org/viewvc/llvm-project?rev=115648&view=rev
Log:
tidy up

Modified:
    llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=115648&r1=115647&r2=115648&view=diff
==============================================================================
--- llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Oct  5 13:39:24 2010
@@ -913,34 +913,28 @@
         BranchInst::Create(I->getSuccessor(Leg), New, Cmp, Old);
         I->removeCase(Leg);
 
-				//const Type *Ty2 = A->getType();
-APInt Mask(cast<IntegerType>(Ty)->getMask());
-APInt KnownZero(Mask.getBitWidth(), 0), KnownOne(Mask.getBitWidth(), 0);
-ComputeMaskedBits(OrigCondition, Mask, KnownZero, KnownOne);
-APInt KnownZeroInverted(~KnownZero);
-unsigned unknown = KnownZeroInverted.countPopulation();
-if (unknown > 2) return true;
-unknown += KnownOne.countPopulation();
-if (unknown > 2) return true;
-APInt Middle(KnownZeroInverted | KnownOne);
-Middle.clear(KnownZeroInverted.countTrailingZeros());
- ConstantInt *Mid(cast<ConstantInt>(ConstantInt::get(Ty, Middle)));
-if (unsigned MidLeg = I->findCaseValue(Mid)) {
-        BasicBlock *New2 = New->splitBasicBlock(I, New->getName()+".switch2");        
-        New->getTerminator()->eraseFromParent();
-				Instruction *MidCmp = new ICmpInst(*New, CmpInst::ICMP_EQ, OrigCondition, Mid, "mid?");
-        BranchInst::Create(I->getSuccessor(MidLeg), New2, MidCmp, New);
-        I->removeCase(MidLeg);
-}
+        APInt Mask(cast<IntegerType>(Ty)->getMask());
+        APInt KnownZero(Mask.getBitWidth(), 0), KnownOne(Mask.getBitWidth(), 0);
+        ComputeMaskedBits(OrigCondition, Mask, KnownZero, KnownOne);
+        APInt KnownZeroInverted(~KnownZero);
+        unsigned unknown = KnownZeroInverted.countPopulation();
+        if (unknown > 2) return true;
+        unknown += KnownOne.countPopulation();
+        if (unknown > 2) return true;
+        APInt Middle(KnownZeroInverted | KnownOne);
+        Middle.clear(KnownZeroInverted.countTrailingZeros());
+        ConstantInt *Mid(cast<ConstantInt>(ConstantInt::get(Ty, Middle)));
+        if (unsigned MidLeg = I->findCaseValue(Mid)) {
+          BasicBlock *New2 = New->splitBasicBlock(I, New->getName()+".switch2");        
+          New->getTerminator()->eraseFromParent();
+          Instruction *MidCmp = new ICmpInst(*New, CmpInst::ICMP_EQ, OrigCondition, Mid, "mid?");
+          BranchInst::Create(I->getSuccessor(MidLeg), New2, MidCmp, New);
+          I->removeCase(MidLeg);
+        }
         return true;
       }
     }
   }
-  else {
-//APInt KnownZero, KnownOne;
-//ComputeMaskedBits(condition, cast<IntegerType>(Ty)->getMask(), KnownZero, KnownOne);
-return false;
-  }
 
   return false;
 }





More information about the llvm-branch-commits mailing list