summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-03-27 17:49:27 +0000
committerReid Kleckner <reid@kleckner.net>2014-03-27 17:49:27 +0000
commit63b11ef6d40b719d555c1398ca05b1f477ecfe39 (patch)
treec9d1f41f4b3e4bf7db62725d68efb3313a82bb52 /test
parent0c6d96cf160f2a6c63f59b5ab7e7a6bbe903ede3 (diff)
downloadllvm-63b11ef6d40b719d555c1398ca05b1f477ecfe39.tar.gz
llvm-63b11ef6d40b719d555c1398ca05b1f477ecfe39.tar.bz2
llvm-63b11ef6d40b719d555c1398ca05b1f477ecfe39.tar.xz
InstCombine: Don't combine constants on unsigned icmps
Fixes a miscompile introduced in r204912. It would miscompile code like (unsigned)(a + -49) <= 5U. The transform would turn this into (unsigned)a < 55U, which would return true for values in [0, 49], when it should not. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204948 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/icmp.ll10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll
index 2e3ff24f6b..63fefc0877 100644
--- a/test/Transforms/InstCombine/icmp.ll
+++ b/test/Transforms/InstCombine/icmp.ll
@@ -1409,3 +1409,13 @@ entry:
%conv = zext i1 %cmp to i32
ret i32 %conv
}
+
+; CHECK-LABEL: icmp_add_const_ult
+; CHECK: %cmp = icmp ult i32 %add, 6
+define i32 @icmp_add_const_ult(i32 %a) #0 {
+entry:
+ %add = add nsw i32 %a, -49
+ %cmp = icmp ult i32 %add, 6
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}