2010-09-21 20:41:19 +02:00
|
|
|
; RUN: llc < %s -march=x86 | FileCheck %s
|
|
|
|
; <rdar://problem/8449754>
|
|
|
|
|
2010-12-19 23:08:31 +01:00
|
|
|
define i32 @test1(i32 %sum, i32 %x) nounwind readnone ssp {
|
2010-09-21 20:41:19 +02:00
|
|
|
entry:
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test1:
|
2014-07-15 17:03:32 +02:00
|
|
|
; CHECK: cmpl %eax, %edx
|
2010-09-21 20:41:19 +02:00
|
|
|
; CHECK-NOT: addl
|
2014-07-15 17:03:32 +02:00
|
|
|
; CHECK: adcl %ecx, %eax
|
2010-09-21 20:41:19 +02:00
|
|
|
%add4 = add i32 %x, %sum
|
|
|
|
%cmp = icmp ult i32 %add4, %x
|
|
|
|
%inc = zext i1 %cmp to i32
|
|
|
|
%z.0 = add i32 %add4, %inc
|
|
|
|
ret i32 %z.0
|
|
|
|
}
|
2010-12-19 23:08:31 +01:00
|
|
|
|
|
|
|
; Instcombine transforms test1 into test2:
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test2:
|
2010-12-19 23:08:31 +01:00
|
|
|
; CHECK: movl
|
|
|
|
; CHECK-NEXT: addl
|
2011-05-08 20:36:07 +02:00
|
|
|
; CHECK-NEXT: adcl $0
|
2010-12-19 23:08:31 +01:00
|
|
|
; CHECK-NEXT: ret
|
|
|
|
define i32 @test2(i32 %sum, i32 %x) nounwind readnone ssp {
|
|
|
|
entry:
|
|
|
|
%uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %x, i32 %sum)
|
|
|
|
%0 = extractvalue { i32, i1 } %uadd, 0
|
|
|
|
%cmp = extractvalue { i32, i1 } %uadd, 1
|
|
|
|
%inc = zext i1 %cmp to i32
|
|
|
|
%z.0 = add i32 %0, %inc
|
|
|
|
ret i32 %z.0
|
|
|
|
}
|
|
|
|
|
2012-11-01 00:11:48 +01:00
|
|
|
; <rdar://problem/12579915>
|
|
|
|
define i32 @test3(i32 %x, i32 %y, i32 %res) nounwind uwtable readnone ssp {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ugt i32 %x, %y
|
|
|
|
%dec = sext i1 %cmp to i32
|
|
|
|
%dec.res = add nsw i32 %dec, %res
|
|
|
|
ret i32 %dec.res
|
2013-07-13 22:38:47 +02:00
|
|
|
; CHECK-LABEL: test3:
|
2012-11-01 00:11:48 +01:00
|
|
|
; CHECK: cmpl
|
|
|
|
; CHECK: sbbl
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
2010-12-19 23:08:31 +01:00
|
|
|
declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
|