Skip to content

Commit bbbdb23

Browse files
authored
[DirectX] Set module-level flag LowPrecisionPresent in DXIL Shader Flags Analysis (#129109)
Fixes #114561
1 parent 25a29ce commit bbbdb23

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

llvm/lib/Target/DirectX/DXILShaderFlags.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ void ModuleShaderFlags::updateFunctionFlags(ComputedShaderFlags &CSF,
9999
}
100100
}
101101

102+
if (!CSF.LowPrecisionPresent)
103+
CSF.LowPrecisionPresent =
104+
I.getType()->isIntegerTy(16) || I.getType()->isHalfTy();
105+
106+
if (!CSF.LowPrecisionPresent) {
107+
for (const Value *Op : I.operands()) {
108+
if (Op->getType()->isIntegerTy(16) || Op->getType()->isHalfTy()) {
109+
CSF.LowPrecisionPresent = true;
110+
break;
111+
}
112+
}
113+
}
114+
102115
if (auto *II = dyn_cast<IntrinsicInst>(&I)) {
103116
switch (II->getIntrinsicID()) {
104117
default:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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: 0x00000020
8+
;CHECK-NEXT: ;
9+
;CHECK-NEXT: ; Note: shader requires additional functionality:
10+
;CHECK-NEXT: ; Note: extra DXIL module flags:
11+
;CHECK-NEXT: ; D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
12+
;CHECK-NEXT: ;
13+
;CHECK-NEXT: ; Shader Flags for Module Functions
14+
15+
;CHECK-LABEL: ; Function add_i16 : 0x00000020
16+
define i16 @add_i16(i16 %a, i16 %b) #0 {
17+
%sum = add i16 %a, %b
18+
ret i16 %sum
19+
}
20+
21+
;CHECK-LABEL: ; Function add_i32 : 0x00000000
22+
define i32 @add_i32(i32 %a, i32 %b) #0 {
23+
%sum = add i32 %a, %b
24+
ret i32 %sum
25+
}
26+
27+
;CHECK-LABEL: ; Function add_half : 0x00000020
28+
define half @add_half(half %a, half %b) #0 {
29+
%sum = fadd half %a, %b
30+
ret half %sum
31+
}
32+
33+
attributes #0 = { convergent norecurse nounwind "hlsl.export"}
34+
35+
; DXC: - Name: SFI0
36+
; DXC-NEXT: Size: 8
37+
; DXC-NOT: Flags:
38+
; DXC: ...

0 commit comments

Comments
 (0)