1
1
; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
2
2
3
- ; CHECK: %dx.types.i32c = type { i32, i1 }
3
+ ; This test exercises the lowering of the intrinsic @llvm.uadd.with.overflow. i32 to the UAddc DXIL op
4
4
5
+ ; CHECK-DAG: [[DX_TYPES_I32C:%dx\.types\.i32c]] = type { i32, i1 }
6
+
7
+ ; NOTE: The uint2 overload of AddUint64 HLSL uses @llvm.uadd.with.overflow.i32, resulting in one UAddc op
5
8
define noundef i32 @test_UAddc (i32 noundef %a , i32 noundef %b ) {
6
9
; CHECK-LABEL: define noundef i32 @test_UAddc(
7
10
; CHECK-SAME: i32 noundef [[A:%.*]], i32 noundef [[B:%.*]]) {
8
- ; CHECK-NEXT: [[UADDC:%.*]] = call [[DX_TYPES_I32C:%dx\.types\.i32c ]] @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A]], i32 [[B]]) #[[ATTR0:[0-9]+]]
11
+ ; CHECK-NEXT: [[UADDC:%.*]] = call [[DX_TYPES_I32C]] @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A]], i32 [[B]]) #[[ATTR0:[0-9]+]]
9
12
; CHECK-NEXT: [[CARRY:%.*]] = extractvalue [[DX_TYPES_I32C]] [[UADDC]], 1
10
13
; CHECK-NEXT: [[SUM:%.*]] = extractvalue [[DX_TYPES_I32C]] [[UADDC]], 0
11
14
; CHECK-NEXT: [[CARRY_ZEXT:%.*]] = zext i1 [[CARRY]] to i32
@@ -20,12 +23,13 @@ define noundef i32 @test_UAddc(i32 noundef %a, i32 noundef %b) {
20
23
ret i32 %result
21
24
}
22
25
26
+ ; NOTE: The uint4 overload of AddUint64 HLSL uses @llvm.uadd.with.overflow.v2i32, resulting in two UAddc ops after scalarization
23
27
define noundef <2 x i32 > @test_UAddc_vec2 (<2 x i32 > noundef %a , <2 x i32 > noundef %b ) {
24
28
; CHECK-LABEL: define noundef <2 x i32> @test_UAddc_vec2(
25
29
; CHECK-SAME: <2 x i32> noundef [[A:%.*]], <2 x i32> noundef [[B:%.*]]) {
26
30
; CHECK-NEXT: [[A_I0:%.*]] = extractelement <2 x i32> [[A]], i64 0
27
31
; CHECK-NEXT: [[B_I0:%.*]] = extractelement <2 x i32> [[B]], i64 0
28
- ; CHECK-NEXT: [[UADDC_I0:%.*]] = call [[DX_TYPES_I32C:%dx\.types\.i32c ]] @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A_I0]], i32 [[B_I0]]) #[[ATTR0]]
32
+ ; CHECK-NEXT: [[UADDC_I0:%.*]] = call [[DX_TYPES_I32C]] @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A_I0]], i32 [[B_I0]]) #[[ATTR0]]
29
33
; CHECK-NEXT: [[A_I1:%.*]] = extractelement <2 x i32> [[A]], i64 1
30
34
; CHECK-NEXT: [[B_I1:%.*]] = extractelement <2 x i32> [[B]], i64 1
31
35
; CHECK-NEXT: [[UADDC_I1:%.*]] = call [[DX_TYPES_I32C]] @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A_I1]], i32 [[B_I1]]) #[[ATTR0]]
@@ -56,7 +60,7 @@ define noundef <2 x i32> @test_UAddc_vec2(<2 x i32> noundef %a, <2 x i32> nounde
56
60
define noundef i32 @test_UAddc_insert (i32 noundef %a , i32 noundef %b ) {
57
61
; CHECK-LABEL: define noundef i32 @test_UAddc_insert(
58
62
; CHECK-SAME: i32 noundef [[A:%.*]], i32 noundef [[B:%.*]]) {
59
- ; CHECK-NEXT: [[UADDC:%.*]] = call [[DX_TYPES_I32C:%dx\.types\.i32c ]] @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A]], i32 [[B]]) #[[ATTR0]]
63
+ ; CHECK-NEXT: [[UADDC:%.*]] = call [[DX_TYPES_I32C]] @dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A]], i32 [[B]]) #[[ATTR0]]
60
64
; CHECK-NEXT: [[UNUSED:%.*]] = insertvalue [[DX_TYPES_I32C]] [[UADDC]], i32 [[A]], 0
61
65
; CHECK-NEXT: [[RESULT:%.*]] = extractvalue [[DX_TYPES_I32C]] [[UADDC]], 0
62
66
; CHECK-NEXT: ret i32 [[RESULT]]
0 commit comments