Skip to content

Commit 132c553

Browse files
spalltex3d
andauthored
Update Validator to reject 16 bit IsSpecialFloat overload before SM6.9 (microsoft#7736)
Updates the validator to error when a 16 bit IsSpecialFloat Op is used before SM6.9 Adds a new validation error message. Add tests to show error. Closes microsoft#7657 --------- Co-authored-by: Tex Riddell <[email protected]>
1 parent 7ed2d26 commit 132c553

File tree

4 files changed

+159
-1
lines changed

4 files changed

+159
-1
lines changed

docs/DXIL.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,6 +3298,7 @@ SM.INVALIDRESOURCEKIND Invalid resources
32983298
SM.INVALIDSAMPLERFEEDBACKTYPE Invalid sampler feedback type.
32993299
SM.INVALIDTEXTUREKINDONUAV TextureCube[Array] resources are not supported with UAVs.
33003300
SM.ISOLINEOUTPUTPRIMITIVEMISMATCH Hull Shader declared with IsoLine Domain must specify output primitive point or line. Triangle_cw or triangle_ccw output are not compatible with the IsoLine Domain.
3301+
SM.ISSPECIALFLOAT 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
33013302
SM.MAXMSSMSIZE Total Thread Group Shared Memory storage is %0, exceeded %1.
33023303
SM.MAXTGSMSIZE Total Thread Group Shared Memory storage is %0, exceeded %1.
33033304
SM.MAXTHEADGROUP Declared Thread Group Count %0 (X*Y*Z) is beyond the valid maximum of %1.

lib/DxilValidation/DxilValidation.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,15 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
24432443
case DXIL::OpCode::VectorAccumulate:
24442444

24452445
break;
2446-
2446+
case DXIL::OpCode::IsInf:
2447+
case DXIL::OpCode::IsNaN:
2448+
case DXIL::OpCode::IsFinite:
2449+
case DXIL::OpCode::IsNormal: {
2450+
if (!ValCtx.DxilMod.GetShaderModel()->IsSM69Plus() &&
2451+
CI->getOperand(1)->getType()->getScalarType()->isHalfTy())
2452+
ValCtx.EmitInstrFormatError(CI, ValidationRule::SmIsSpecialFloat, {});
2453+
break;
2454+
}
24472455
default:
24482456
// TODO: make sure every Opcode is checked.
24492457
// Skip opcodes don't need special check.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
; RUN: not %dxv %s 2>&1 | FileCheck %s
2+
3+
; The purpose of this test is to verify an error is emitted when pre-sm6.9
4+
; 16bit IsSpecialFloat OpClass is used.
5+
6+
target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
7+
target triple = "dxil-ms-dx"
8+
9+
; Function Attrs: nounwind readnone
10+
define i1 @"\01?test_isinf@@YA_N$f16@@Z"(half %h) #0 {
11+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
12+
%1 = call i1 @dx.op.isSpecialFloat.f16(i32 9, half %h) ; IsInf(value)
13+
ret i1 %1
14+
}
15+
16+
; Function Attrs: nounwind readnone
17+
define <2 x i1> @"\01?test_isinf2@@YA?AV?$vector@_N$01@@V?$vector@$f16@$01@@@Z"(<2 x half> %h) #0 {
18+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
19+
%1 = call <2 x i1> @dx.op.isSpecialFloat.v2f16(i32 9, <2 x half> %h) ; IsInf(value)
20+
ret <2 x i1> %1
21+
}
22+
23+
; Function Attrs: nounwind readnone
24+
define <3 x i1> @"\01?test_isinf3@@YA?AV?$vector@_N$02@@V?$vector@$f16@$02@@@Z"(<3 x half> %h) #0 {
25+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
26+
%1 = call <3 x i1> @dx.op.isSpecialFloat.v3f16(i32 9, <3 x half> %h) ; IsInf(value)
27+
ret <3 x i1> %1
28+
}
29+
30+
; Function Attrs: nounwind readnone
31+
define <4 x i1> @"\01?test_isinf4@@YA?AV?$vector@_N$03@@V?$vector@$f16@$03@@@Z"(<4 x half> %h) #0 {
32+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
33+
%1 = call <4 x i1> @dx.op.isSpecialFloat.v4f16(i32 9, <4 x half> %h) ; IsInf(value)
34+
ret <4 x i1> %1
35+
}
36+
37+
; Function Attrs: nounwind readnone
38+
define i1 @"\01?test_isnan@@YA_N$f16@@Z"(half %h) #0 {
39+
; CHECK-DAG: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
40+
%1 = call i1 @dx.op.isSpecialFloat.f16(i32 8, half %h) ; IsNaN(value)
41+
ret i1 %1
42+
}
43+
44+
; Function Attrs: nounwind readnone
45+
define <2 x i1> @"\01?test_isnan2@@YA?AV?$vector@_N$01@@V?$vector@$f16@$01@@@Z"(<2 x half> %h) #0 {
46+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
47+
%1 = call <2 x i1> @dx.op.isSpecialFloat.v2f16(i32 8, <2 x half> %h) ; IsNaN(value)
48+
ret <2 x i1> %1
49+
}
50+
51+
; Function Attrs: nounwind readnone
52+
define <3 x i1> @"\01?test_isnan3@@YA?AV?$vector@_N$02@@V?$vector@$f16@$02@@@Z"(<3 x half> %h) #0 {
53+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
54+
%1 = call <3 x i1> @dx.op.isSpecialFloat.v3f16(i32 8, <3 x half> %h) ; IsNaN(value)
55+
ret <3 x i1> %1
56+
}
57+
58+
; Function Attrs: nounwind readnone
59+
define <4 x i1> @"\01?test_isnan4@@YA?AV?$vector@_N$03@@V?$vector@$f16@$03@@@Z"(<4 x half> %h) #0 {
60+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
61+
%1 = call <4 x i1> @dx.op.isSpecialFloat.v4f16(i32 8, <4 x half> %h) ; IsNaN(value)
62+
ret <4 x i1> %1
63+
}
64+
65+
; Function Attrs: nounwind readnone
66+
define i1 @"\01?test_isfinite@@YA_N$f16@@Z"(half %h) #0 {
67+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
68+
%1 = call i1 @dx.op.isSpecialFloat.f16(i32 10, half %h) ; IsFinite(value)
69+
ret i1 %1
70+
}
71+
72+
; Function Attrs: nounwind readnone
73+
define <2 x i1> @"\01?test_isfinite2@@YA?AV?$vector@_N$01@@V?$vector@$f16@$01@@@Z"(<2 x half> %h) #0 {
74+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
75+
%1 = call <2 x i1> @dx.op.isSpecialFloat.v2f16(i32 10, <2 x half> %h) ; IsFinite(value)
76+
ret <2 x i1> %1
77+
}
78+
79+
; Function Attrs: nounwind readnone
80+
define <3 x i1> @"\01?test_isfinite3@@YA?AV?$vector@_N$02@@V?$vector@$f16@$02@@@Z"(<3 x half> %h) #0 {
81+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
82+
%1 = call <3 x i1> @dx.op.isSpecialFloat.v3f16(i32 10, <3 x half> %h) ; IsFinite(value)
83+
ret <3 x i1> %1
84+
}
85+
86+
; Function Attrs: nounwind readnone
87+
define <4 x i1> @"\01?test_isfinite4@@YA?AV?$vector@_N$03@@V?$vector@$f16@$03@@@Z"(<4 x half> %h) #0 {
88+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
89+
%1 = call <4 x i1> @dx.op.isSpecialFloat.v4f16(i32 10, <4 x half> %h) ; IsFinite(value)
90+
ret <4 x i1> %1
91+
}
92+
93+
; Function Attrs: nounwind readnone
94+
define i1 @"\01?test_isnormal@@YA_N$f16@@Z"(half %h) #0 {
95+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
96+
%1 = call i1 @dx.op.isSpecialFloat.f16(i32 11, half %h) ; IsNormal(value)
97+
ret i1 %1
98+
}
99+
100+
; Function Attrs: nounwind readnone
101+
define <2 x i1> @"\01?test_isnormal2@@YA?AV?$vector@_N$01@@V?$vector@$f16@$01@@@Z"(<2 x half> %h) #0 {
102+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
103+
%1 = call <2 x i1> @dx.op.isSpecialFloat.v2f16(i32 11, <2 x half> %h) ; IsNormal(value)
104+
ret <2 x i1> %1
105+
}
106+
107+
; Function Attrs: nounwind readnone
108+
define <3 x i1> @"\01?test_isnormal3@@YA?AV?$vector@_N$02@@V?$vector@$f16@$02@@@Z"(<3 x half> %h) #0 {
109+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
110+
%1 = call <3 x i1> @dx.op.isSpecialFloat.v3f16(i32 11, <3 x half> %h) ; IsNormal(value)
111+
ret <3 x i1> %1
112+
}
113+
114+
; Function Attrs: nounwind readnone
115+
define <4 x i1> @"\01?test_isnormal4@@YA?AV?$vector@_N$03@@V?$vector@$f16@$03@@@Z"(<4 x half> %h) #0 {
116+
; CHECK-DAG: error: 16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.
117+
%1 = call <4 x i1> @dx.op.isSpecialFloat.v4f16(i32 11, <4 x half> %h) ; IsNormal(value)
118+
ret <4 x i1> %1
119+
}
120+
121+
; Function Attrs: nounwind readnone
122+
declare i1 @dx.op.isSpecialFloat.f16(i32, half) #0
123+
124+
; Function Attrs: nounwind readnone
125+
declare <2 x i1> @dx.op.isSpecialFloat.v2f16(i32, <2 x half>) #0
126+
127+
; Function Attrs: nounwind readnone
128+
declare <3 x i1> @dx.op.isSpecialFloat.v3f16(i32, <3 x half>) #0
129+
130+
; Function Attrs: nounwind readnone
131+
declare <4 x i1> @dx.op.isSpecialFloat.v4f16(i32, <4 x half>) #0
132+
133+
attributes #0 = { nounwind readnone }
134+
135+
!llvm.ident = !{!0}
136+
!dx.version = !{!1}
137+
!dx.valver = !{!1}
138+
!dx.shaderModel = !{!2}
139+
!dx.entryPoints = !{!3}
140+
141+
!0 = !{!"dxc(private) 1.8.0.14983 (main, 2da0a54f1)"}
142+
!1 = !{i32 1, i32 8}
143+
!2 = !{!"lib", i32 6, i32 8}
144+
!3 = !{null, !"", null, null, !4}
145+
!4 = !{i32 0, i64 8388640}

utils/hct/hctdb.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8736,6 +8736,10 @@ def build_valrules(self):
87368736
"Sm.AmplificationShaderPayloadSizeDeclared",
87378737
"For amplification shader with entry '%0', payload size %1 is greater than declared size of %2 bytes.",
87388738
)
8739+
self.add_valrule(
8740+
"Sm.IsSpecialFloat",
8741+
"16 bit IsSpecialFloat overloads require Shader Model 6.9 or higher.",
8742+
)
87398743

87408744
# fxc relaxed check of gradient check.
87418745
# self.add_valrule("Uni.NoUniInDiv", "TODO - No instruction requiring uniform execution can be present in divergent block")

0 commit comments

Comments
 (0)