summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/icmp.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-21 04:04:05 +0000
committerChris Lattner <sabre@nondot.org>2009-12-21 04:04:05 +0000
commit3bf68155563cac6848d671848d875f41ad7e3277 (patch)
tree396f56075134fb3d58520cdb78c3ccbe58bf6409 /test/Transforms/InstCombine/icmp.ll
parent2799bafb98676c000388f8636d58064f2646266e (diff)
downloadllvm-3bf68155563cac6848d671848d875f41ad7e3277.tar.gz
llvm-3bf68155563cac6848d671848d875f41ad7e3277.tar.bz2
llvm-3bf68155563cac6848d671848d875f41ad7e3277.tar.xz
enhance x-(-A) -> x+A to preserve NUW/NSW.
Use the presence of NSW/NUW to fold "icmp (x+cst), x" to a constant in cases where it would otherwise be undefined behavior. Surprisingly (to me at least), this triggers hundreds of the times in a few benchmarks: lencode, ldecode, and 466.h264ref seem to *really* like this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91812 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/icmp.ll')
-rw-r--r--test/Transforms/InstCombine/icmp.ll13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll
index f469dd4ef2..79fa220752 100644
--- a/test/Transforms/InstCombine/icmp.ll
+++ b/test/Transforms/InstCombine/icmp.ll
@@ -69,6 +69,7 @@ entry:
%a = add i32 %x, -1
%b = icmp ult i32 %a, %x
ret i1 %b
+; CHECK: @test7
; CHECK: %b = icmp ne i32 %x, 0
; CHECK: ret i1 %b
}
@@ -78,6 +79,7 @@ entry:
%a = add i32 %x, -1
%b = icmp eq i32 %a, %x
ret i1 %b
+; CHECK: @test8
; CHECK: ret i1 false
}
@@ -86,6 +88,7 @@ entry:
%a = add i32 %x, -2
%b = icmp ugt i32 %x, %a
ret i1 %b
+; CHECK: @test9
; CHECK: icmp ugt i32 %x, 1
; CHECK: ret i1 %b
}
@@ -96,6 +99,16 @@ entry:
%b = icmp slt i32 %a, %x
ret i1 %b
+; CHECK: @test10
; CHECK: %b = icmp ne i32 %x, -2147483648
; CHECK: ret i1 %b
}
+
+define i1 @test11(i32 %x) {
+ %a = add nsw i32 %x, 8
+ %b = icmp slt i32 %x, %a
+ ret i1 %b
+; CHECK: @test11
+; CHECK: ret i1 true
+}
+