1 ; RUN: llc < %s -march=x86 | FileCheck %s
2 ; <rdar://problem/8449754>
4 define i32 @test1(i32 %sum, i32 %x) nounwind readnone ssp {
7 ; CHECK: cmpl %ecx, %eax
10 %add4 = add i32 %x, %sum
11 %cmp = icmp ult i32 %add4, %x
12 %inc = zext i1 %cmp to i32
13 %z.0 = add i32 %add4, %inc
17 ; Instcombine transforms test1 into test2:
23 define i32 @test2(i32 %sum, i32 %x) nounwind readnone ssp {
25 %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %x, i32 %sum)
26 %0 = extractvalue { i32, i1 } %uadd, 0
27 %cmp = extractvalue { i32, i1 } %uadd, 1
28 %inc = zext i1 %cmp to i32
29 %z.0 = add i32 %0, %inc
33 ; <rdar://problem/12579915>
34 define i32 @test3(i32 %x, i32 %y, i32 %res) nounwind uwtable readnone ssp {
36 %cmp = icmp ugt i32 %x, %y
37 %dec = sext i1 %cmp to i32
38 %dec.res = add nsw i32 %dec, %res
46 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone