tint: Implement const-eval of quantizeToF16

Bug: tint:1581
Change-Id: I5cf9806bde7875282d3b67731dbb88666523f598
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108142
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2022-11-02 17:29:48 +00:00
committed by Dawn LUCI CQ
parent 749abeaafb
commit c81f9dce07
26 changed files with 193 additions and 240 deletions

View File

@@ -1,5 +1,5 @@
void quantizeToF16_12e50e() {
float res = float(min16float(1.0f));
float res = 1.0f;
}
struct tint_symbol {

View File

@@ -1,5 +1,5 @@
void quantizeToF16_12e50e() {
float res = float(min16float(1.0f));
float res = 1.0f;
}
struct tint_symbol {

View File

@@ -1,12 +1,7 @@
#version 310 es
float tint_quantizeToF16(float param_0) {
return unpackHalf2x16(packHalf2x16(vec2(param_0))).x;
}
void quantizeToF16_12e50e() {
float res = tint_quantizeToF16(1.0f);
float res = 1.0f;
}
vec4 vertex_main() {
@@ -25,13 +20,8 @@ void main() {
#version 310 es
precision mediump float;
float tint_quantizeToF16(float param_0) {
return unpackHalf2x16(packHalf2x16(vec2(param_0))).x;
}
void quantizeToF16_12e50e() {
float res = tint_quantizeToF16(1.0f);
float res = 1.0f;
}
void fragment_main() {
@@ -44,13 +34,8 @@ void main() {
}
#version 310 es
float tint_quantizeToF16(float param_0) {
return unpackHalf2x16(packHalf2x16(vec2(param_0))).x;
}
void quantizeToF16_12e50e() {
float res = tint_quantizeToF16(1.0f);
float res = 1.0f;
}
void compute_main() {

View File

@@ -2,7 +2,7 @@
using namespace metal;
void quantizeToF16_12e50e() {
float res = float(half(1.0f));
float res = 1.0f;
}
struct tint_symbol {

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 30
; Bound: 29
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -32,33 +32,32 @@
%9 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%_ptr_Function_float = OpTypePointer Function %float
%17 = OpTypeFunction %v4float
%16 = OpTypeFunction %v4float
%quantizeToF16_12e50e = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
%13 = OpQuantizeToF16 %float %float_1
OpStore %res %13
OpStore %res %float_1
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %17
%19 = OpLabel
%20 = OpFunctionCall %void %quantizeToF16_12e50e
%vertex_main_inner = OpFunction %v4float None %16
%18 = OpLabel
%19 = OpFunctionCall %void %quantizeToF16_12e50e
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
%22 = OpLabel
%23 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %23
%21 = OpLabel
%22 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %22
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
%25 = OpLabel
%26 = OpFunctionCall %void %quantizeToF16_12e50e
%24 = OpLabel
%25 = OpFunctionCall %void %quantizeToF16_12e50e
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
%28 = OpLabel
%29 = OpFunctionCall %void %quantizeToF16_12e50e
%27 = OpLabel
%28 = OpFunctionCall %void %quantizeToF16_12e50e
OpReturn
OpFunctionEnd

View File

@@ -1,5 +1,5 @@
void quantizeToF16_2cddf3() {
float2 res = float2(min16float2((1.0f).xx));
float2 res = (1.0f).xx;
}
struct tint_symbol {

View File

@@ -1,5 +1,5 @@
void quantizeToF16_2cddf3() {
float2 res = float2(min16float2((1.0f).xx));
float2 res = (1.0f).xx;
}
struct tint_symbol {

View File

@@ -1,12 +1,7 @@
#version 310 es
vec2 tint_quantizeToF16(vec2 param_0) {
return unpackHalf2x16(packHalf2x16(param_0));
}
void quantizeToF16_2cddf3() {
vec2 res = tint_quantizeToF16(vec2(1.0f));
vec2 res = vec2(1.0f);
}
vec4 vertex_main() {
@@ -25,13 +20,8 @@ void main() {
#version 310 es
precision mediump float;
vec2 tint_quantizeToF16(vec2 param_0) {
return unpackHalf2x16(packHalf2x16(param_0));
}
void quantizeToF16_2cddf3() {
vec2 res = tint_quantizeToF16(vec2(1.0f));
vec2 res = vec2(1.0f);
}
void fragment_main() {
@@ -44,13 +34,8 @@ void main() {
}
#version 310 es
vec2 tint_quantizeToF16(vec2 param_0) {
return unpackHalf2x16(packHalf2x16(param_0));
}
void quantizeToF16_2cddf3() {
vec2 res = tint_quantizeToF16(vec2(1.0f));
vec2 res = vec2(1.0f);
}
void compute_main() {

View File

@@ -2,7 +2,7 @@
using namespace metal;
void quantizeToF16_2cddf3() {
float2 res = float2(half2(float2(1.0f)));
float2 res = float2(1.0f);
}
struct tint_symbol {

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 45
; Bound: 32
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -12,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
OpName %tint_quantizeToF16 "tint_quantizeToF16"
OpName %v "v"
OpName %quantizeToF16_2cddf3 "quantizeToF16_2cddf3"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -30,54 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%v2float = OpTypeVector %float 2
%9 = OpTypeFunction %v2float %v2float
%uint = OpTypeInt 32 0
%16 = OpConstantNull %uint
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid
%22 = OpTypeFunction %void
%9 = OpTypeFunction %void
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
%28 = OpConstantComposite %v2float %float_1 %float_1
%15 = OpConstantComposite %v2float %float_1 %float_1
%_ptr_Function_v2float = OpTypePointer Function %v2float
%31 = OpConstantNull %v2float
%32 = OpTypeFunction %v4float
%tint_quantizeToF16 = OpFunction %v2float None %9
%v = OpFunctionParameter %v2float
%13 = OpLabel
%17 = OpCompositeExtract %float %v 0
%14 = OpQuantizeToF16 %float %17
%20 = OpCompositeExtract %float %v 1
%18 = OpQuantizeToF16 %float %20
%21 = OpCompositeConstruct %v2float %14 %18
OpReturnValue %21
OpFunctionEnd
%quantizeToF16_2cddf3 = OpFunction %void None %22
%25 = OpLabel
%res = OpVariable %_ptr_Function_v2float Function %31
%26 = OpFunctionCall %v2float %tint_quantizeToF16 %28
OpStore %res %26
%18 = OpConstantNull %v2float
%19 = OpTypeFunction %v4float
%quantizeToF16_2cddf3 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v2float Function %18
OpStore %res %15
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %32
%34 = OpLabel
%35 = OpFunctionCall %void %quantizeToF16_2cddf3
%vertex_main_inner = OpFunction %v4float None %19
%21 = OpLabel
%22 = OpFunctionCall %void %quantizeToF16_2cddf3
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %22
%37 = OpLabel
%38 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %38
%vertex_main = OpFunction %void None %9
%24 = OpLabel
%25 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %22
%40 = OpLabel
%41 = OpFunctionCall %void %quantizeToF16_2cddf3
%fragment_main = OpFunction %void None %9
%27 = OpLabel
%28 = OpFunctionCall %void %quantizeToF16_2cddf3
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %22
%43 = OpLabel
%44 = OpFunctionCall %void %quantizeToF16_2cddf3
%compute_main = OpFunction %void None %9
%30 = OpLabel
%31 = OpFunctionCall %void %quantizeToF16_2cddf3
OpReturn
OpFunctionEnd

View File

@@ -1,5 +1,5 @@
void quantizeToF16_cba294() {
float4 res = float4(min16float4((1.0f).xxxx));
float4 res = (1.0f).xxxx;
}
struct tint_symbol {

View File

@@ -1,5 +1,5 @@
void quantizeToF16_cba294() {
float4 res = float4(min16float4((1.0f).xxxx));
float4 res = (1.0f).xxxx;
}
struct tint_symbol {

View File

@@ -1,14 +1,7 @@
#version 310 es
vec4 tint_quantizeToF16(vec4 param_0) {
return vec4(
unpackHalf2x16(packHalf2x16(param_0.xy)),
unpackHalf2x16(packHalf2x16(param_0.zw)));
}
void quantizeToF16_cba294() {
vec4 res = tint_quantizeToF16(vec4(1.0f));
vec4 res = vec4(1.0f);
}
vec4 vertex_main() {
@@ -27,15 +20,8 @@ void main() {
#version 310 es
precision mediump float;
vec4 tint_quantizeToF16(vec4 param_0) {
return vec4(
unpackHalf2x16(packHalf2x16(param_0.xy)),
unpackHalf2x16(packHalf2x16(param_0.zw)));
}
void quantizeToF16_cba294() {
vec4 res = tint_quantizeToF16(vec4(1.0f));
vec4 res = vec4(1.0f);
}
void fragment_main() {
@@ -48,15 +34,8 @@ void main() {
}
#version 310 es
vec4 tint_quantizeToF16(vec4 param_0) {
return vec4(
unpackHalf2x16(packHalf2x16(param_0.xy)),
unpackHalf2x16(packHalf2x16(param_0.zw)));
}
void quantizeToF16_cba294() {
vec4 res = tint_quantizeToF16(vec4(1.0f));
vec4 res = vec4(1.0f);
}
void compute_main() {

View File

@@ -2,7 +2,7 @@
using namespace metal;
void quantizeToF16_cba294() {
float4 res = float4(half4(float4(1.0f)));
float4 res = float4(1.0f);
}
struct tint_symbol {

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 49
; Bound: 30
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -12,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
OpName %tint_quantizeToF16 "tint_quantizeToF16"
OpName %v "v"
OpName %quantizeToF16_cba294 "quantizeToF16_cba294"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -30,58 +28,37 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%9 = OpTypeFunction %v4float %v4float
%uint = OpTypeInt 32 0
%15 = OpConstantNull %uint
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%uint_3 = OpConstant %uint 3
%void = OpTypeVoid
%27 = OpTypeFunction %void
%9 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%33 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Function_v4float = OpTypePointer Function %v4float
%36 = OpTypeFunction %v4float
%tint_quantizeToF16 = OpFunction %v4float None %9
%v = OpFunctionParameter %v4float
%17 = OpTypeFunction %v4float
%quantizeToF16_cba294 = OpFunction %void None %9
%12 = OpLabel
%16 = OpCompositeExtract %float %v 0
%13 = OpQuantizeToF16 %float %16
%19 = OpCompositeExtract %float %v 1
%17 = OpQuantizeToF16 %float %19
%22 = OpCompositeExtract %float %v 2
%20 = OpQuantizeToF16 %float %22
%25 = OpCompositeExtract %float %v 3
%23 = OpQuantizeToF16 %float %25
%26 = OpCompositeConstruct %v4float %13 %17 %20 %23
OpReturnValue %26
OpFunctionEnd
%quantizeToF16_cba294 = OpFunction %void None %27
%30 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
%31 = OpFunctionCall %v4float %tint_quantizeToF16 %33
OpStore %res %31
OpStore %res %14
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %36
%38 = OpLabel
%39 = OpFunctionCall %void %quantizeToF16_cba294
%vertex_main_inner = OpFunction %v4float None %17
%19 = OpLabel
%20 = OpFunctionCall %void %quantizeToF16_cba294
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %27
%41 = OpLabel
%42 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %42
%vertex_main = OpFunction %void None %9
%22 = OpLabel
%23 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %27
%44 = OpLabel
%45 = OpFunctionCall %void %quantizeToF16_cba294
%fragment_main = OpFunction %void None %9
%25 = OpLabel
%26 = OpFunctionCall %void %quantizeToF16_cba294
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %27
%47 = OpLabel
%48 = OpFunctionCall %void %quantizeToF16_cba294
%compute_main = OpFunction %void None %9
%28 = OpLabel
%29 = OpFunctionCall %void %quantizeToF16_cba294
OpReturn
OpFunctionEnd

View File

@@ -1,5 +1,5 @@
void quantizeToF16_e8fd14() {
float3 res = float3(min16float3((1.0f).xxx));
float3 res = (1.0f).xxx;
}
struct tint_symbol {

View File

@@ -1,5 +1,5 @@
void quantizeToF16_e8fd14() {
float3 res = float3(min16float3((1.0f).xxx));
float3 res = (1.0f).xxx;
}
struct tint_symbol {

View File

@@ -1,14 +1,7 @@
#version 310 es
vec3 tint_quantizeToF16(vec3 param_0) {
return vec3(
unpackHalf2x16(packHalf2x16(param_0.xy)),
unpackHalf2x16(packHalf2x16(param_0.zz)).x);
}
void quantizeToF16_e8fd14() {
vec3 res = tint_quantizeToF16(vec3(1.0f));
vec3 res = vec3(1.0f);
}
vec4 vertex_main() {
@@ -27,15 +20,8 @@ void main() {
#version 310 es
precision mediump float;
vec3 tint_quantizeToF16(vec3 param_0) {
return vec3(
unpackHalf2x16(packHalf2x16(param_0.xy)),
unpackHalf2x16(packHalf2x16(param_0.zz)).x);
}
void quantizeToF16_e8fd14() {
vec3 res = tint_quantizeToF16(vec3(1.0f));
vec3 res = vec3(1.0f);
}
void fragment_main() {
@@ -48,15 +34,8 @@ void main() {
}
#version 310 es
vec3 tint_quantizeToF16(vec3 param_0) {
return vec3(
unpackHalf2x16(packHalf2x16(param_0.xy)),
unpackHalf2x16(packHalf2x16(param_0.zz)).x);
}
void quantizeToF16_e8fd14() {
vec3 res = tint_quantizeToF16(vec3(1.0f));
vec3 res = vec3(1.0f);
}
void compute_main() {

View File

@@ -2,7 +2,7 @@
using namespace metal;
void quantizeToF16_e8fd14() {
float3 res = float3(half3(float3(1.0f)));
float3 res = float3(1.0f);
}
struct tint_symbol {

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 48
; Bound: 32
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -12,8 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
OpName %tint_quantizeToF16 "tint_quantizeToF16"
OpName %v "v"
OpName %quantizeToF16_e8fd14 "quantizeToF16_e8fd14"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -30,57 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%v3float = OpTypeVector %float 3
%9 = OpTypeFunction %v3float %v3float
%uint = OpTypeInt 32 0
%16 = OpConstantNull %uint
%uint_1 = OpConstant %uint 1
%uint_2 = OpConstant %uint 2
%void = OpTypeVoid
%25 = OpTypeFunction %void
%9 = OpTypeFunction %void
%v3float = OpTypeVector %float 3
%float_1 = OpConstant %float 1
%31 = OpConstantComposite %v3float %float_1 %float_1 %float_1
%15 = OpConstantComposite %v3float %float_1 %float_1 %float_1
%_ptr_Function_v3float = OpTypePointer Function %v3float
%34 = OpConstantNull %v3float
%35 = OpTypeFunction %v4float
%tint_quantizeToF16 = OpFunction %v3float None %9
%v = OpFunctionParameter %v3float
%13 = OpLabel
%17 = OpCompositeExtract %float %v 0
%14 = OpQuantizeToF16 %float %17
%20 = OpCompositeExtract %float %v 1
%18 = OpQuantizeToF16 %float %20
%23 = OpCompositeExtract %float %v 2
%21 = OpQuantizeToF16 %float %23
%24 = OpCompositeConstruct %v3float %14 %18 %21
OpReturnValue %24
OpFunctionEnd
%quantizeToF16_e8fd14 = OpFunction %void None %25
%28 = OpLabel
%res = OpVariable %_ptr_Function_v3float Function %34
%29 = OpFunctionCall %v3float %tint_quantizeToF16 %31
OpStore %res %29
%18 = OpConstantNull %v3float
%19 = OpTypeFunction %v4float
%quantizeToF16_e8fd14 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v3float Function %18
OpStore %res %15
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %35
%37 = OpLabel
%38 = OpFunctionCall %void %quantizeToF16_e8fd14
%vertex_main_inner = OpFunction %v4float None %19
%21 = OpLabel
%22 = OpFunctionCall %void %quantizeToF16_e8fd14
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %25
%40 = OpLabel
%41 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %41
%vertex_main = OpFunction %void None %9
%24 = OpLabel
%25 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %25
%43 = OpLabel
%44 = OpFunctionCall %void %quantizeToF16_e8fd14
%fragment_main = OpFunction %void None %9
%27 = OpLabel
%28 = OpFunctionCall %void %quantizeToF16_e8fd14
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %25
%46 = OpLabel
%47 = OpFunctionCall %void %quantizeToF16_e8fd14
%compute_main = OpFunction %void None %9
%30 = OpLabel
%31 = OpFunctionCall %void %quantizeToF16_e8fd14
OpReturn
OpFunctionEnd