[llvm-commits] [llvm] r86952 - in /llvm/trunk/lib: Analysis/LazyValueInfo.cpp Transforms/Scalar/JumpThreading.cpp
Chris Lattner
sabre at nondot.org
Wed Nov 11 20:57:14 PST 2009
Author: lattner
Date: Wed Nov 11 22:57:13 2009
New Revision: 86952
URL: http://llvm.org/viewvc/llvm-project?rev=86952&view=rev
Log:
various fixes to the lattice transfer functions.
Modified:
llvm/trunk/lib/Analysis/LazyValueInfo.cpp
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=86952&r1=86951&r2=86952&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Nov 11 22:57:13 2009
@@ -141,19 +141,40 @@
if (RHS.isNotConstant()) {
if (isNotConstant()) {
- if (getNotConstant() != RHS.getNotConstant())
+ if (getNotConstant() != RHS.getNotConstant() ||
+ isa<ConstantExpr>(getNotConstant()) ||
+ isa<ConstantExpr>(RHS.getNotConstant()))
return markOverdefined();
return false;
}
- if (isConstant() && getConstant() != RHS.getNotConstant())
- return markOverdefined();
+ if (isConstant()) {
+ if (getConstant() == RHS.getNotConstant() ||
+ isa<ConstantExpr>(RHS.getNotConstant()) ||
+ isa<ConstantExpr>(getConstant()))
+ return markOverdefined();
+ return markNotConstant(RHS.getNotConstant());
+ }
+
+ assert(isUndefined() && "Unexpected lattice");
return markNotConstant(RHS.getNotConstant());
}
- // RHS must be a constant, we must be undef or constant.
- if (isConstant() && getConstant() != RHS.getConstant())
+ // RHS must be a constant, we must be undef, constant, or notconstant.
+ if (isUndefined())
+ return markConstant(RHS.getConstant());
+
+ if (isConstant()) {
+ if (getConstant() != RHS.getConstant())
+ return markOverdefined();
+ return false;
+ }
+
+ // If we are known "!=4" and RHS is "==5", stay at "!=4".
+ if (getNotConstant() == RHS.getConstant() ||
+ isa<ConstantExpr>(getNotConstant()) ||
+ isa<ConstantExpr>(RHS.getConstant()))
return markOverdefined();
- return markConstant(RHS.getConstant());
+ return false;
}
};
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86952&r1=86951&r2=86952&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed Nov 11 22:57:13 2009
@@ -275,6 +275,12 @@
/// predecessor based on its terminator.
//
if (LVI) {
+ // FIXME: change this to use the more-rich 'getPredicateOnEdge' method if
+ // "I" is a non-local compare-with-a-constant instruction. This would be
+ // able to handle value inequalities better, for example if the compare is
+ // "X < 4" and "X < 3" is known true but "X < 4" itself is not available.
+ // Perhaps getConstantOnEdge should be smart enough to do this?
+
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
// If the value is known by LazyValueInfo to be a constant in a
// predecessor, use that information to try to thread this block.
More information about the llvm-commits
mailing list