Skip to content

Commit 1a95215

Browse files
authored
[DirectX] Set function-level flag Int64Ops in DXIL Shader Flags Analysis (#129089)
Fixes #114562
1 parent 04ab8a5 commit 1a95215

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

llvm/lib/Target/DirectX/DXILShaderFlags.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ void ModuleShaderFlags::updateFunctionFlags(ComputedShaderFlags &CSF,
112112
}
113113
}
114114

115+
if (!CSF.Int64Ops)
116+
CSF.Int64Ops = I.getType()->isIntegerTy(64);
117+
118+
if (!CSF.Int64Ops) {
119+
for (const Value *Op : I.operands()) {
120+
if (Op->getType()->isIntegerTy(64)) {
121+
CSF.Int64Ops = true;
122+
break;
123+
}
124+
}
125+
}
126+
115127
if (auto *II = dyn_cast<IntrinsicInst>(&I)) {
116128
switch (II->getIntrinsicID()) {
117129
default:

llvm/test/CodeGen/DirectX/ShaderFlags/double-extensions.ll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
target triple = "dxil-pc-shadermodel6.7-library"
44

55
; CHECK: ; Combined Shader Flags for Module
6-
; CHECK-NEXT: ; Shader Flags Value: 0x00000044
6+
; CHECK-NEXT: ; Shader Flags Value: 0x00100044
77

88
; CHECK: ; Note: shader requires additional functionality:
99
; CHECK-NEXT: ; Double-precision floating point
1010
; CHECK-NEXT: ; Double-precision extensions for 11.1
11+
; CHECK-NEXT: ; 64-Bit integer
1112
; CHECK-NEXT: ; Note: extra DXIL module flags:
1213
; CHECK-NEXT: ;
1314
; CHECK-NEXT: ; Shader Flags for Module Functions
1415

15-
;CHECK: ; Function top_level : 0x00000044
16+
;CHECK: ; Function top_level : 0x00100044
1617
define double @top_level() #0 {
1718
%r = call double @test_uitofp_i64(i64 5)
1819
ret double %r
@@ -25,13 +26,13 @@ define double @test_fdiv_double(double %a, double %b) #0 {
2526
ret double %res
2627
}
2728

28-
; CHECK: ; Function test_uitofp_i64 : 0x00000044
29+
; CHECK: ; Function test_uitofp_i64 : 0x00100044
2930
define double @test_uitofp_i64(i64 %a) #0 {
3031
%r = uitofp i64 %a to double
3132
ret double %r
3233
}
3334

34-
; CHECK: ; Function test_sitofp_i64 : 0x00000044
35+
; CHECK: ; Function test_sitofp_i64 : 0x00100044
3536
define double @test_sitofp_i64(i64 %a) #0 {
3637
%r = sitofp i64 %a to double
3738
ret double %r
@@ -43,7 +44,7 @@ define i32 @test_fptoui_i32(double %a) #0 {
4344
ret i32 %r
4445
}
4546

46-
; CHECK: ; Function test_fptosi_i64 : 0x00000044
47+
; CHECK: ; Function test_fptosi_i64 : 0x00100044
4748
define i64 @test_fptosi_i64(double %a) #0 {
4849
%r = fptosi double %a to i64
4950
ret i64 %r
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
2+
; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
3+
4+
target triple = "dxil-pc-shadermodel6.7-library"
5+
6+
;CHECK: ; Combined Shader Flags for Module
7+
;CHECK-NEXT: ; Shader Flags Value: 0x00100000
8+
;CHECK-NEXT: ;
9+
;CHECK-NEXT: ; Note: shader requires additional functionality:
10+
;CHECK-NEXT: ; 64-Bit integer
11+
;CHECK-NEXT: ; Note: extra DXIL module flags:
12+
;CHECK-NEXT: ;
13+
;CHECK-NEXT: ; Shader Flags for Module Functions
14+
;CHECK-NEXT: ; Function add : 0x00100000
15+
16+
define i64 @add(i64 %a, i64 %b) #0 {
17+
%sum = add i64 %a, %b
18+
ret i64 %sum
19+
}
20+
21+
attributes #0 = { convergent norecurse nounwind "hlsl.export"}
22+
23+
; DXC: - Name: SFI0
24+
; DXC-NEXT: Size: 8
25+
; DXC-NEXT: Flags:
26+
; DXC-NOT: {{[A-Za-z]+: +true}}
27+
; DXC: Int64Ops: true
28+
; DXC-NOT: {{[A-Za-z]+: +true}}
29+
; DXC: NextUnusedBit: false
30+
; DXC: ...

llvm/test/CodeGen/DirectX/ShaderFlags/propagate-function-flags-test.ll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
target triple = "dxil-pc-shadermodel6.7-library"
44

55
; CHECK: ; Combined Shader Flags for Module
6-
; CHECK-NEXT: ; Shader Flags Value: 0x00000044
6+
; CHECK-NEXT: ; Shader Flags Value: 0x00100044
77
; CHECK-NEXT: ;
88
; CHECK-NEXT: ; Note: shader requires additional functionality:
99
; CHECK-NEXT: ; Double-precision floating point
1010
; CHECK-NEXT: ; Double-precision extensions for 11.1
11+
; CHECK-NEXT: ; 64-Bit integer
1112
; CHECK-NEXT: ; Note: extra DXIL module flags:
1213
; CHECK-NEXT: ;
1314
; CHECK-NEXT: ; Shader Flags for Module Functions
@@ -55,13 +56,13 @@ define double @call_get_uitofp_flag(i32 noundef %0) local_unnamed_addr #0 {
5556
ret double %2
5657
}
5758

58-
; CHECK: ; Function call_get_fptoui_flag : 0x00000044
59+
; CHECK: ; Function call_get_fptoui_flag : 0x00100044
5960
define double @call_get_fptoui_flag(double noundef %0) local_unnamed_addr #0 {
6061
%2 = tail call double @get_fptoui_flag(double noundef %0)
6162
ret double %2
6263
}
6364

64-
; CHECK: ; Function get_fptoui_flag : 0x00000044
65+
; CHECK: ; Function get_fptoui_flag : 0x00100044
6566
define double @get_fptoui_flag(double noundef %0) local_unnamed_addr #0 {
6667
%2 = fcmp ugt double %0, 5.000000e+00
6768
br i1 %2, label %6, label %3
@@ -81,7 +82,7 @@ define double @get_fptoui_flag(double noundef %0) local_unnamed_addr #0 {
8182
ret double %10
8283
}
8384

84-
; CHECK: ; Function get_sitofp_uitofp_flag : 0x00000044
85+
; CHECK: ; Function get_sitofp_uitofp_flag : 0x00100044
8586
define double @get_sitofp_uitofp_flag(i64 noundef %0) local_unnamed_addr #0 {
8687
%2 = icmp ult i64 %0, 6
8788
br i1 %2, label %3, label %7
@@ -154,7 +155,7 @@ define double @get_all_doubles_flags(i32 noundef %0) local_unnamed_addr #0 {
154155
ret double %4
155156
}
156157

157-
; CHECK: ; Function main : 0x00000044
158+
; CHECK: ; Function main : 0x00100044
158159
define i32 @main() local_unnamed_addr #0 {
159160
%1 = tail call double @get_fptoui_flag(double noundef 1.000000e+00)
160161
%2 = tail call double @get_sitofp_fdiv_flag(i32 noundef 4)

0 commit comments

Comments
 (0)