[llvm-commits] [llvm] r124188 - in /llvm/trunk: lib/Analysis/ValueTracking.cpp test/Transforms/InstSimplify/2011-01-18-Compare.ll
Duncan Sands
baldrick at free.fr
Tue Jan 25 07:14:15 PST 2011
Author: baldrick
Date: Tue Jan 25 09:14:15 2011
New Revision: 124188
URL: http://llvm.org/viewvc/llvm-project?rev=124188&view=rev
Log:
In which I discover that zero+zero is zero, d'oh!
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/test/Transforms/InstSimplify/2011-01-18-Compare.ll
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=124188&r1=124187&r2=124188&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue Jan 25 09:14:15 2011
@@ -740,10 +740,10 @@
ComputeSignBit(Y, YKnownNonNegative, YKnownNegative, TD, Depth);
// If X and Y are both non-negative (as signed values) then their sum is not
- // zero.
+ // zero unless both X and Y are zero.
if (XKnownNonNegative && YKnownNonNegative)
- return false;
-// return true;
+ if (isKnownNonZero(X, TD, Depth) || isKnownNonZero(Y, TD, Depth))
+ return true;
// If X and Y are both negative (as signed values) then their sum is not
// zero unless both X and Y equal INT_MIN.
Modified: llvm/trunk/test/Transforms/InstSimplify/2011-01-18-Compare.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/2011-01-18-Compare.ll?rev=124188&r1=124187&r2=124188&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/2011-01-18-Compare.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/2011-01-18-Compare.ll Tue Jan 25 09:14:15 2011
@@ -61,11 +61,14 @@
}
define i1 @add(i32 %x, i32 %y) {
+; CHECK: @add
%l = lshr i32 %x, 1
- %r = lshr i32 %y, 1
+ %q = lshr i32 %y, 1
+ %r = or i32 %q, 1
%s = add i32 %l, %r
%c = icmp eq i32 %s, 0
ret i1 %c
+; CHECK: ret i1 false
}
define i1 @add2(i8 %x, i8 %y) {
@@ -78,6 +81,16 @@
; CHECK: ret i1 false
}
+define i1 @add3(i8 %x, i8 %y) {
+; CHECK: @add3
+ %l = zext i8 %x to i32
+ %r = zext i8 %y to i32
+ %s = add i32 %l, %r
+ %c = icmp eq i32 %s, 0
+ ret i1 %c
+; CHECK: ret i1 %c
+}
+
define i1 @addpowtwo(i32 %x, i32 %y) {
; CHECK: @addpowtwo
%l = lshr i32 %x, 1
More information about the llvm-commits
mailing list