summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/signed-comparison.ll
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-04-25 17:12:48 +0000
committerDan Gohman <gohman@apple.com>2009-04-25 17:12:48 +0000
commit1c8491ecc768c410a552bc3441e456fedc2736ff (patch)
tree774f979e8a63d1f8a09f6af959514b073082f208 /test/Transforms/InstCombine/signed-comparison.ll
parent4128700ab11d0db62e5ba7ed8a8fc301c7aaa8b1 (diff)
downloadllvm-1c8491ecc768c410a552bc3441e456fedc2736ff.tar.gz
llvm-1c8491ecc768c410a552bc3441e456fedc2736ff.tar.bz2
llvm-1c8491ecc768c410a552bc3441e456fedc2736ff.tar.xz
Add several more icmp simplifications. Transform signed comparisons
into unsigned ones when the operands are known to have the same sign bit value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70053 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/signed-comparison.ll')
-rw-r--r--test/Transforms/InstCombine/signed-comparison.ll28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/signed-comparison.ll b/test/Transforms/InstCombine/signed-comparison.ll
new file mode 100644
index 0000000000..fdf150f9c6
--- /dev/null
+++ b/test/Transforms/InstCombine/signed-comparison.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis > %t
+; RUN: not grep zext %t
+; RUN: not grep slt %t
+; RUN: grep {icmp ult} %t
+
+; Instcombine should convert the zext+slt into a simple ult.
+
+define void @foo(double* %p) nounwind {
+entry:
+ br label %bb
+
+bb:
+ %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %bb ]
+ %t0 = and i64 %indvar, 65535
+ %t1 = getelementptr double* %p, i64 %t0
+ %t2 = load double* %t1, align 8
+ %t3 = mul double %t2, 2.2
+ store double %t3, double* %t1, align 8
+ %i.04 = trunc i64 %indvar to i16
+ %t4 = add i16 %i.04, 1
+ %t5 = zext i16 %t4 to i32
+ %t6 = icmp slt i32 %t5, 500
+ %indvar.next = add i64 %indvar, 1
+ br i1 %t6, label %bb, label %return
+
+return:
+ ret void
+}