tint: Use MergeReturn transform in SPIR-V backend

Bug: tint:1627
Change-Id: I5a3639543b076e6f666bfcca8c61b22db7f2630e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107363
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2022-10-31 15:41:41 +00:00
committed by Dawn LUCI CQ
parent a3343d92d3
commit 3e1bc0a6da
13 changed files with 1302 additions and 1096 deletions

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 26
; Bound: 32
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,42 +9,52 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %tint_return_flag "tint_return_flag"
OpName %tint_return_value "tint_return_value"
OpName %i "i"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%5 = OpTypeFunction %int
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%12 = OpConstantNull %bool
%_ptr_Function_int = OpTypePointer Function %int
%11 = OpConstantNull %int
%15 = OpConstantNull %int
%int_1 = OpConstant %int 1
%int_4 = OpConstant %int 4
%bool = OpTypeBool
%true = OpConstantTrue %bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %int None %5
%8 = OpLabel
%i = OpVariable %_ptr_Function_int Function %11
OpBranch %12
%12 = OpLabel
OpLoopMerge %13 %14 None
OpBranch %15
%15 = OpLabel
%16 = OpLoad %int %i
%18 = OpIAdd %int %16 %int_1
OpStore %i %18
%19 = OpLoad %int %i
%21 = OpSGreaterThan %bool %19 %int_4
OpSelectionMerge %23 None
OpBranchConditional %21 %24 %23
%24 = OpLabel
%25 = OpLoad %int %i
OpReturnValue %25
%23 = OpLabel
OpBranch %14
%14 = OpLabel
OpBranch %12
%13 = OpLabel
OpReturnValue %11
%tint_return_flag = OpVariable %_ptr_Function_bool Function %12
%tint_return_value = OpVariable %_ptr_Function_int Function %15
%i = OpVariable %_ptr_Function_int Function %15
OpBranch %17
%17 = OpLabel
OpLoopMerge %18 %19 None
OpBranch %20
%20 = OpLabel
%21 = OpLoad %int %i
%23 = OpIAdd %int %21 %int_1
OpStore %i %23
%24 = OpLoad %int %i
%26 = OpSGreaterThan %bool %24 %int_4
OpSelectionMerge %27 None
OpBranchConditional %26 %28 %27
%28 = OpLabel
OpStore %tint_return_flag %true
%30 = OpLoad %int %i
OpStore %tint_return_value %30
OpBranch %18
%27 = OpLabel
OpBranch %19
%19 = OpLabel
OpBranch %17
%18 = OpLabel
%31 = OpLoad %int %tint_return_value
OpReturnValue %31
OpFunctionEnd

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 29
; Bound: 39
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,15 +9,20 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %tint_return_flag "tint_return_flag"
OpName %tint_return_value "tint_return_value"
OpName %i "i"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%5 = OpTypeFunction %int
%_ptr_Function_int = OpTypePointer Function %int
%11 = OpConstantNull %int
%int_4 = OpConstant %int 4
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%12 = OpConstantNull %bool
%_ptr_Function_int = OpTypePointer Function %int
%15 = OpConstantNull %int
%int_4 = OpConstant %int 4
%true = OpConstantTrue %bool
%int_1 = OpConstant %int 1
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
@@ -25,29 +30,43 @@
OpFunctionEnd
%f = OpFunction %int None %5
%8 = OpLabel
%i = OpVariable %_ptr_Function_int Function %11
OpBranch %12
%12 = OpLabel
OpLoopMerge %13 %14 None
OpBranch %15
%15 = OpLabel
%16 = OpLoad %int %i
%18 = OpSGreaterThan %bool %16 %int_4
OpSelectionMerge %20 None
OpBranchConditional %18 %21 %20
%21 = OpLabel
%22 = OpLoad %int %i
OpReturnValue %22
%tint_return_flag = OpVariable %_ptr_Function_bool Function %12
%tint_return_value = OpVariable %_ptr_Function_int Function %15
%i = OpVariable %_ptr_Function_int Function %15
OpBranch %17
%17 = OpLabel
OpLoopMerge %18 %19 None
OpBranch %20
%20 = OpLabel
OpBranch %14
%14 = OpLabel
%23 = OpLoad %int %i
%25 = OpIAdd %int %23 %int_1
OpStore %i %25
%26 = OpLoad %int %i
%27 = OpIEqual %bool %26 %int_4
OpBranchConditional %27 %13 %12
%13 = OpLabel
%21 = OpLoad %int %i
%23 = OpSGreaterThan %bool %21 %int_4
OpSelectionMerge %24 None
OpBranchConditional %23 %25 %24
%25 = OpLabel
OpStore %tint_return_flag %true
%27 = OpLoad %int %i
OpStore %tint_return_value %27
OpBranch %18
%24 = OpLabel
OpBranch %19
%19 = OpLabel
%28 = OpLoad %int %i
OpReturnValue %28
%30 = OpIAdd %int %28 %int_1
OpStore %i %30
%31 = OpLoad %int %i
%32 = OpIEqual %bool %31 %int_4
OpBranchConditional %32 %18 %17
%18 = OpLabel
%34 = OpLoad %bool %tint_return_flag
%33 = OpLogicalNot %bool %34
OpSelectionMerge %35 None
OpBranchConditional %33 %36 %35
%36 = OpLabel
OpStore %tint_return_flag %true
%37 = OpLoad %int %i
OpStore %tint_return_value %37
OpBranch %35
%35 = OpLabel
%38 = OpLoad %int %tint_return_value
OpReturnValue %38
OpFunctionEnd

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 26
; Bound: 32
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,15 +9,20 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %tint_return_flag "tint_return_flag"
OpName %tint_return_value "tint_return_value"
OpName %i "i"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%5 = OpTypeFunction %int
%_ptr_Function_int = OpTypePointer Function %int
%11 = OpConstantNull %int
%int_4 = OpConstant %int 4
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%12 = OpConstantNull %bool
%_ptr_Function_int = OpTypePointer Function %int
%15 = OpConstantNull %int
%int_4 = OpConstant %int 4
%true = OpConstantTrue %bool
%int_1 = OpConstant %int 1
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
@@ -25,26 +30,31 @@
OpFunctionEnd
%f = OpFunction %int None %5
%8 = OpLabel
%i = OpVariable %_ptr_Function_int Function %11
OpBranch %12
%12 = OpLabel
OpLoopMerge %13 %14 None
OpBranch %15
%15 = OpLabel
%16 = OpLoad %int %i
%18 = OpSGreaterThan %bool %16 %int_4
OpSelectionMerge %20 None
OpBranchConditional %18 %21 %20
%21 = OpLabel
%22 = OpLoad %int %i
OpReturnValue %22
%tint_return_flag = OpVariable %_ptr_Function_bool Function %12
%tint_return_value = OpVariable %_ptr_Function_int Function %15
%i = OpVariable %_ptr_Function_int Function %15
OpBranch %17
%17 = OpLabel
OpLoopMerge %18 %19 None
OpBranch %20
%20 = OpLabel
OpBranch %14
%14 = OpLabel
%23 = OpLoad %int %i
%25 = OpIAdd %int %23 %int_1
OpStore %i %25
OpBranch %12
%13 = OpLabel
OpReturnValue %11
%21 = OpLoad %int %i
%23 = OpSGreaterThan %bool %21 %int_4
OpSelectionMerge %24 None
OpBranchConditional %23 %25 %24
%25 = OpLabel
OpStore %tint_return_flag %true
%27 = OpLoad %int %i
OpStore %tint_return_value %27
OpBranch %18
%24 = OpLabel
OpBranch %19
%19 = OpLabel
%28 = OpLoad %int %i
%30 = OpIAdd %int %28 %int_1
OpStore %i %30
OpBranch %17
%18 = OpLabel
%31 = OpLoad %int %tint_return_value
OpReturnValue %31
OpFunctionEnd

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 37
; Bound: 43
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,17 +9,22 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %tint_return_flag "tint_return_flag"
OpName %tint_return_value "tint_return_value"
OpName %i "i"
OpName %j "j"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%5 = OpTypeFunction %int
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%12 = OpConstantNull %bool
%_ptr_Function_int = OpTypePointer Function %int
%11 = OpConstantNull %int
%15 = OpConstantNull %int
%int_1 = OpConstant %int 1
%int_4 = OpConstant %int 4
%bool = OpTypeBool
%true = OpConstantTrue %bool
%int_2 = OpConstant %int 2
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
@@ -27,45 +32,52 @@
OpFunctionEnd
%f = OpFunction %int None %5
%8 = OpLabel
%i = OpVariable %_ptr_Function_int Function %11
%j = OpVariable %_ptr_Function_int Function %11
OpBranch %13
%13 = OpLabel
OpLoopMerge %14 %15 None
OpBranch %16
%16 = OpLabel
%17 = OpLoad %int %i
%19 = OpIAdd %int %17 %int_1
OpStore %i %19
%20 = OpLoad %int %i
%22 = OpSGreaterThan %bool %20 %int_4
OpSelectionMerge %24 None
OpBranchConditional %22 %25 %24
%25 = OpLabel
OpReturnValue %int_1
%24 = OpLabel
OpBranch %26
%26 = OpLabel
OpLoopMerge %27 %28 None
OpBranch %29
%tint_return_flag = OpVariable %_ptr_Function_bool Function %12
%tint_return_value = OpVariable %_ptr_Function_int Function %15
%i = OpVariable %_ptr_Function_int Function %15
%j = OpVariable %_ptr_Function_int Function %15
OpBranch %18
%18 = OpLabel
OpLoopMerge %19 %20 None
OpBranch %21
%21 = OpLabel
%22 = OpLoad %int %i
%24 = OpIAdd %int %22 %int_1
OpStore %i %24
%25 = OpLoad %int %i
%27 = OpSGreaterThan %bool %25 %int_4
OpSelectionMerge %28 None
OpBranchConditional %27 %29 %28
%29 = OpLabel
%30 = OpLoad %int %j
%31 = OpIAdd %int %30 %int_1
OpStore %j %31
%32 = OpLoad %int %j
%33 = OpSGreaterThan %bool %32 %int_4
OpSelectionMerge %34 None
OpBranchConditional %33 %35 %34
%35 = OpLabel
OpReturnValue %int_2
%34 = OpLabel
OpBranch %28
OpStore %tint_return_flag %true
OpStore %tint_return_value %int_1
OpBranch %19
%28 = OpLabel
OpBranch %26
%27 = OpLabel
OpBranch %15
%15 = OpLabel
OpBranch %13
%14 = OpLabel
OpReturnValue %11
OpBranch %31
%31 = OpLabel
OpLoopMerge %32 %33 None
OpBranch %34
%34 = OpLabel
%35 = OpLoad %int %j
%36 = OpIAdd %int %35 %int_1
OpStore %j %36
%37 = OpLoad %int %j
%38 = OpSGreaterThan %bool %37 %int_4
OpSelectionMerge %39 None
OpBranchConditional %38 %40 %39
%40 = OpLabel
OpStore %tint_return_flag %true
OpStore %tint_return_value %int_2
OpBranch %32
%39 = OpLabel
OpBranch %33
%33 = OpLabel
OpBranch %31
%32 = OpLabel
OpBranch %19
%20 = OpLabel
OpBranch %18
%19 = OpLabel
%42 = OpLoad %int %tint_return_value
OpReturnValue %42
OpFunctionEnd

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 37
; Bound: 43
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@@ -9,16 +9,21 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %tint_return_flag "tint_return_flag"
OpName %tint_return_value "tint_return_value"
OpName %i "i"
OpName %j "j"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%5 = OpTypeFunction %int
%_ptr_Function_int = OpTypePointer Function %int
%11 = OpConstantNull %int
%int_4 = OpConstant %int 4
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%12 = OpConstantNull %bool
%_ptr_Function_int = OpTypePointer Function %int
%15 = OpConstantNull %int
%int_4 = OpConstant %int 4
%true = OpConstantTrue %bool
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%unused_entry_point = OpFunction %void None %1
@@ -27,45 +32,52 @@
OpFunctionEnd
%f = OpFunction %int None %5
%8 = OpLabel
%i = OpVariable %_ptr_Function_int Function %11
%j = OpVariable %_ptr_Function_int Function %11
OpBranch %13
%13 = OpLabel
OpLoopMerge %14 %15 None
OpBranch %16
%16 = OpLabel
%17 = OpLoad %int %i
%19 = OpSGreaterThan %bool %17 %int_4
OpSelectionMerge %21 None
OpBranchConditional %19 %22 %21
%22 = OpLabel
OpReturnValue %int_1
%tint_return_flag = OpVariable %_ptr_Function_bool Function %12
%tint_return_value = OpVariable %_ptr_Function_int Function %15
%i = OpVariable %_ptr_Function_int Function %15
%j = OpVariable %_ptr_Function_int Function %15
OpBranch %18
%18 = OpLabel
OpLoopMerge %19 %20 None
OpBranch %21
%21 = OpLabel
OpBranch %24
%24 = OpLabel
OpLoopMerge %25 %26 None
OpBranch %27
%27 = OpLabel
%28 = OpLoad %int %j
%29 = OpSGreaterThan %bool %28 %int_4
OpSelectionMerge %30 None
OpBranchConditional %29 %31 %30
%31 = OpLabel
OpReturnValue %int_2
%30 = OpLabel
OpBranch %26
%22 = OpLoad %int %i
%24 = OpSGreaterThan %bool %22 %int_4
OpSelectionMerge %25 None
OpBranchConditional %24 %26 %25
%26 = OpLabel
%33 = OpLoad %int %j
%34 = OpIAdd %int %33 %int_1
OpStore %j %34
OpBranch %24
OpStore %tint_return_flag %true
OpStore %tint_return_value %int_1
OpBranch %19
%25 = OpLabel
OpBranch %15
%15 = OpLabel
%35 = OpLoad %int %i
%36 = OpIAdd %int %35 %int_1
OpStore %i %36
OpBranch %13
%14 = OpLabel
OpReturnValue %11
OpBranch %29
%29 = OpLabel
OpLoopMerge %30 %31 None
OpBranch %32
%32 = OpLabel
%33 = OpLoad %int %j
%34 = OpSGreaterThan %bool %33 %int_4
OpSelectionMerge %35 None
OpBranchConditional %34 %36 %35
%36 = OpLabel
OpStore %tint_return_flag %true
OpStore %tint_return_value %int_2
OpBranch %30
%35 = OpLabel
OpBranch %31
%31 = OpLabel
%38 = OpLoad %int %j
%39 = OpIAdd %int %38 %int_1
OpStore %j %39
OpBranch %29
%30 = OpLabel
OpBranch %19
%20 = OpLabel
%40 = OpLoad %int %i
%41 = OpIAdd %int %40 %int_1
OpStore %i %41
OpBranch %18
%19 = OpLabel
%42 = OpLoad %int %tint_return_value
OpReturnValue %42
OpFunctionEnd