summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/overflow.ll
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-12-17 18:08:00 +0000
committerOwen Anderson <resistor@mac.com>2010-12-17 18:08:00 +0000
commite63dda51c2b230215837063dba73e9299f8c0aba (patch)
treed5ccebf8887037dd5710f83531f65ca1659482b7 /test/Transforms/InstCombine/overflow.ll
parent31f3578b00a2ea85fb730b690f0478529103c748 (diff)
downloadllvm-e63dda51c2b230215837063dba73e9299f8c0aba.tar.gz
llvm-e63dda51c2b230215837063dba73e9299f8c0aba.tar.bz2
llvm-e63dda51c2b230215837063dba73e9299f8c0aba.tar.xz
Reapply r121905 (automatic synthesis of @llvm.sadd.with.overflow) with a fix for a bug that manifested itself
on the DragonEgg self-host bot. Unfortunately, the testcase is pretty messy and doesn't reduce well due to interactions with other parts of InstCombine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/overflow.ll')
-rw-r--r--test/Transforms/InstCombine/overflow.ll27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/overflow.ll b/test/Transforms/InstCombine/overflow.ll
new file mode 100644
index 0000000000..f3f8ca3d61
--- /dev/null
+++ b/test/Transforms/InstCombine/overflow.ll
@@ -0,0 +1,27 @@
+; RUN: opt -S -instcombine < %s | FileCheck %s
+; <rdar://problem/8558713>
+
+; CHECK: @test1
+define i32 @test1(i32 %a, i32 %b) nounwind ssp {
+entry:
+; CHECK-NOT: sext
+ %conv = sext i32 %a to i64
+ %conv2 = sext i32 %b to i64
+ %add = add nsw i64 %conv2, %conv
+ %add.off = add i64 %add, 2147483648
+; CHECK: llvm.sadd.with.overflow
+ %0 = icmp ugt i64 %add.off, 4294967295
+ br i1 %0, label %if.then, label %if.end
+
+if.then:
+ %call = tail call i32 (...)* @throwAnExceptionOrWhatever() nounwind
+ br label %if.end
+
+if.end:
+; CHECK-NOT: trunc
+ %conv9 = trunc i64 %add to i32
+; CHECK: ret i32
+ ret i32 %conv9
+}
+
+declare i32 @throwAnExceptionOrWhatever(...)