[llvm-commits] [llvm] r157071 - in /llvm/trunk: lib/Analysis/LazyValueInfo.cpp test/Transforms/CorrelatedValuePropagation/range.ll
Nuno Lopes
nunoplopes at sapo.pt
Fri May 18 14:02:10 PDT 2012
Author: nlopes
Date: Fri May 18 16:02:10 2012
New Revision: 157071
URL: http://llvm.org/viewvc/llvm-project?rev=157071&view=rev
Log:
allow LazyValueInfo::getEdgeValue() to reason about multiple edges from the same switch instruction by doing union of ranges (which may still be conservative, but it's more aggressive than before)
Modified:
llvm/trunk/lib/Analysis/LazyValueInfo.cpp
llvm/trunk/test/Transforms/CorrelatedValuePropagation/range.ll
Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=157071&r1=157070&r2=157071&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Fri May 18 16:02:10 2012
@@ -862,21 +862,16 @@
return true;
}
- // We only know something if there is exactly one value that goes from
- // BBFrom to BBTo.
- unsigned NumEdges = 0;
- ConstantInt *EdgeVal = 0;
+ unsigned BitWidth = Val->getType()->getIntegerBitWidth();
+ ConstantRange EdgesVals(BitWidth, false/*isFullSet*/);
for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end();
i != e; ++i) {
if (i.getCaseSuccessor() != BBTo) continue;
- if (NumEdges++) break;
- EdgeVal = i.getCaseValue();
- }
- assert(EdgeVal && "Missing successor?");
- if (NumEdges == 1) {
- Result = LVILatticeVal::get(EdgeVal);
- return true;
+ ConstantRange EdgeVal(i.getCaseValue()->getValue());
+ EdgesVals = EdgesVals.unionWith(EdgeVal);
}
+ Result = LVILatticeVal::getRange(EdgesVals);
+ return true;
}
}
Modified: llvm/trunk/test/Transforms/CorrelatedValuePropagation/range.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CorrelatedValuePropagation/range.ll?rev=157071&r1=157070&r2=157071&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/CorrelatedValuePropagation/range.ll (original)
+++ llvm/trunk/test/Transforms/CorrelatedValuePropagation/range.ll Fri May 18 16:02:10 2012
@@ -70,3 +70,31 @@
if.end8:
ret i32 4
}
+
+; CHECK: @test4
+define i32 @test4(i32 %c) nounwind {
+ switch i32 %c, label %sw.default [
+ i32 1, label %sw.bb
+ i32 2, label %sw.bb
+ i32 4, label %sw.bb
+ ]
+
+; CHECK: sw.bb
+sw.bb:
+ %cmp = icmp sge i32 %c, 1
+; CHECK: br i1 true
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then:
+ br label %return
+
+if.end:
+ br label %return
+
+sw.default:
+ br label %return
+
+return:
+ %retval.0 = phi i32 [ 42, %sw.default ], [ 4, %if.then ], [ 9, %if.end ]
+ ret i32 %retval.0
+}
More information about the llvm-commits
mailing list