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,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