1 ; RUN: llc < %s -march=x86 | FileCheck %s 2 ; <rdar://problem/8449754> 3 4 define i32 @test1(i32 %sum, i32 %x) nounwind readnone ssp { 5 entry: 6 ; CHECK-LABEL: test1: 7 ; CHECK: cmpl %ecx, %eax 8 ; CHECK-NOT: addl 9 ; CHECK: adcl $0, %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 14 ret i32 %z.0 15 } 16 17 ; Instcombine transforms test1 into test2: 18 ; CHECK-LABEL: test2: 19 ; CHECK: movl 20 ; CHECK-NEXT: addl 21 ; CHECK-NEXT: adcl $0 22 ; CHECK-NEXT: ret 23 define i32 @test2(i32 %sum, i32 %x) nounwind readnone ssp { 24 entry: 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 30 ret i32 %z.0 31 } 32 33 ; <rdar://problem/12579915> 34 define i32 @test3(i32 %x, i32 %y, i32 %res) nounwind uwtable readnone ssp { 35 entry: 36 %cmp = icmp ugt i32 %x, %y 37 %dec = sext i1 %cmp to i32 38 %dec.res = add nsw i32 %dec, %res 39 ret i32 %dec.res 40 ; CHECK-LABEL: test3: 41 ; CHECK: cmpl 42 ; CHECK: sbbl 43 ; CHECK: ret 44 } 45 46 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone 47