[llvm-commits] [llvm] r39852 - /llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp

Nick Lewycky nicholas at mxc.ca
Fri Jul 13 21:28:05 PDT 2007


Author: nicholas
Date: Fri Jul 13 23:28:04 2007
New Revision: 39852

URL: http://llvm.org/viewvc/llvm-project?rev=39852&view=rev
Log:
Use maximal intersection algorithm exclusively. Fixes miscompile bug.

Modified:
    llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp?rev=39852&r1=39851&r2=39852&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp Fri Jul 13 23:28:04 2007
@@ -938,7 +938,7 @@
             std::lower_bound(begin(), E, std::make_pair(Subtree, empty), swo);
 
         if (I != end() && I->first == Subtree) {
-          ConstantRange CR2 = I->second.intersectWith(CR);
+          ConstantRange CR2 = I->second.maximalIntersectWith(CR);
           assert(!CR2.isEmptySet() && !CR2.isSingleElement() &&
                  "Invalid union of ranges.");
           I->second = CR2;
@@ -970,18 +970,18 @@
       ConstantRange Range(CR.getBitWidth());
 
       if (LV_s == SGT_BIT) {
-        Range = Range.intersectWith(makeConstantRange(
+        Range = Range.maximalIntersectWith(makeConstantRange(
                     hasEQ ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_SGT, CR));
       } else if (LV_s == SLT_BIT) {
-        Range = Range.intersectWith(makeConstantRange(
+        Range = Range.maximalIntersectWith(makeConstantRange(
                     hasEQ ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_SLT, CR));
       }
 
       if (LV_u == UGT_BIT) {
-        Range = Range.intersectWith(makeConstantRange(
+        Range = Range.maximalIntersectWith(makeConstantRange(
                     hasEQ ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_UGT, CR));
       } else if (LV_u == ULT_BIT) {
-        Range = Range.intersectWith(makeConstantRange(
+        Range = Range.maximalIntersectWith(makeConstantRange(
                     hasEQ ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_ULT, CR));
       }
 
@@ -1104,7 +1104,7 @@
       switch (LV) {
       default: assert(!"Impossible lattice value!");
       case NE:
-        return CR1.intersectWith(CR2).isEmptySet();
+        return CR1.maximalIntersectWith(CR2).isEmptySet();
       case ULT:
         return CR1.getUnsignedMax().ult(CR2.getUnsignedMin());
       case ULE:
@@ -1170,7 +1170,7 @@
         unsigned i = VN.valueNumber(*I, Subtree);
         ConstantRange CR_Kill = i ? range(i, Subtree) : range(*I);
         if (CR_Kill.isFullSet()) continue;
-        Merged = Merged.intersectWith(CR_Kill);
+        Merged = Merged.maximalIntersectWith(CR_Kill);
       }
 
       if (Merged.isFullSet() || Merged == CR_New) return;
@@ -1180,7 +1180,7 @@
 
     void applyRange(unsigned n, const ConstantRange &CR,
                     DomTreeDFS::Node *Subtree, VRPSolver *VRP) {
-      ConstantRange Merged = CR.intersectWith(range(n, Subtree));
+      ConstantRange Merged = CR.maximalIntersectWith(range(n, Subtree));
       if (Merged.isEmptySet()) {
         markBlock(VRP);
         return;
@@ -1270,14 +1270,14 @@
       ConstantRange CR2 = range(n2, Subtree);
 
       if (!CR1.isSingleElement()) {
-        ConstantRange NewCR1 = CR1.intersectWith(create(LV, CR2));
+        ConstantRange NewCR1 = CR1.maximalIntersectWith(create(LV, CR2));
         if (NewCR1 != CR1)
           applyRange(n1, NewCR1, Subtree, VRP);
       }
 
       if (!CR2.isSingleElement()) {
-        ConstantRange NewCR2 = CR2.intersectWith(create(reversePredicate(LV),
-                                                        CR1));
+        ConstantRange NewCR2 = CR2.maximalIntersectWith(
+                                       create(reversePredicate(LV), CR1));
         if (NewCR2 != CR2)
           applyRange(n2, NewCR2, Subtree, VRP);
       }





More information about the llvm-commits mailing list