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

Gabor Greif ggreif at gmail.com
Fri Oct 1 19:50:04 PDT 2010


Author: ggreif
Date: Fri Oct  1 21:50:04 2010
New Revision: 115403

URL: http://llvm.org/viewvc/llvm-project?rev=115403&view=rev
Log:
fix iterator bug, add masked bits computation (still asserts)

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=115403&r1=115402&r2=115403&view=diff
==============================================================================
--- llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp Fri Oct  1 21:50:04 2010
@@ -23,6 +23,7 @@
 #include "llvm/IntrinsicInst.h"
 #include "llvm/Pass.h"
 #include "llvm/Analysis/ProfileInfo.h"
+#include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Transforms/Utils/AddrModeMatcher.h"
@@ -893,7 +894,7 @@
   if (TruncInst *T = dyn_cast<TruncInst>(condition)) {
     if (Instruction *P = dyn_cast<Instruction>(T->getOperand(0))) { 
       if (Old != P->getParent() ||
-	condition != --BasicBlock::iterator(T)/* TODO: CHEAP TRUNCATES*/)
+	condition != next(BasicBlock::iterator(P))/* TODO: CHEAP TRUNCATES*/)
       return false;
       condition = P;
     }
@@ -910,10 +911,21 @@
         Instruction *Cmp = new ICmpInst(*Old, CmpInst::ICMP_EQ, I->getCondition(), Zero, "tst");
         BranchInst::Create(I->getSuccessor(Leg), New, Cmp, Old);
         I->removeCase(Leg);
+
+
+APInt KnownZero, KnownOne;
+ComputeMaskedBits(A, cast<IntegerType>(Ty)->getMask(), KnownZero, KnownOne);
+
+
         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