blob: f3f8ca3d61d678c4093add682094237d813665ab [file] [log] [blame]
Owen Anderson1294ea72010-12-17 18:08:00 +00001; RUN: opt -S -instcombine < %s | FileCheck %s
2; <rdar://problem/8558713>
3
4; CHECK: @test1
5define i32 @test1(i32 %a, i32 %b) nounwind ssp {
6entry:
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
16if.then:
17 %call = tail call i32 (...)* @throwAnExceptionOrWhatever() nounwind
18 br label %if.end
19
20if.end:
21; CHECK-NOT: trunc
22 %conv9 = trunc i64 %add to i32
23; CHECK: ret i32
24 ret i32 %conv9
25}
26
27declare i32 @throwAnExceptionOrWhatever(...)