Reapply r121905 (automatic synthesis of @llvm.sadd.with.overflow) with a fix for...
[oota-llvm.git] / test / Transforms / InstCombine / overflow.ll
1 ; RUN: opt -S -instcombine < %s | FileCheck %s
2 ; <rdar://problem/8558713>
3
4 ; CHECK: @test1
5 define i32 @test1(i32 %a, i32 %b) nounwind ssp {
6 entry:
7 ; CHECK-NOT: sext
8   %conv = sext i32 %a to i64
9   %conv2 = sext i32 %b to i64
10   %add = add nsw i64 %conv2, %conv
11   %add.off = add i64 %add, 2147483648
12 ; CHECK: llvm.sadd.with.overflow
13   %0 = icmp ugt i64 %add.off, 4294967295
14   br i1 %0, label %if.then, label %if.end
15
16 if.then:
17   %call = tail call i32 (...)* @throwAnExceptionOrWhatever() nounwind
18   br label %if.end
19
20 if.end:
21 ; CHECK-NOT: trunc
22   %conv9 = trunc i64 %add to i32
23 ; CHECK: ret i32
24   ret i32 %conv9
25 }
26
27 declare i32 @throwAnExceptionOrWhatever(...)