diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 3476b480c2..212ac6fdc0 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -1875,31 +1875,48 @@ impl Writer { spirv::SelectionControl::NONE, )); - let accept_id = self.generate_id(); - let reject_id = self.generate_id(); + let accept_id = if accept.is_empty() { + None + } else { + Some(self.generate_id()) + }; + let reject_id = if reject.is_empty() { + None + } else { + Some(self.generate_id()) + }; + function.consume( block, - Instruction::branch_conditional(condition_id, accept_id, reject_id), + Instruction::branch_conditional( + condition_id, + accept_id.unwrap_or(merge_id), + reject_id.unwrap_or(merge_id), + ), ); - self.write_block( - accept_id, - accept, - ir_module, - ir_function, - function, - Some(merge_id), - loop_context, - )?; - self.write_block( - reject_id, - reject, - ir_module, - ir_function, - function, - Some(merge_id), - loop_context, - )?; + if let Some(block_id) = accept_id { + self.write_block( + block_id, + accept, + ir_module, + ir_function, + function, + Some(merge_id), + loop_context, + )?; + } + if let Some(block_id) = reject_id { + self.write_block( + block_id, + reject, + ir_module, + ir_function, + function, + Some(merge_id), + loop_context, + )?; + } block = Block::new(merge_id); } diff --git a/tests/out/boids.spvasm.snap b/tests/out/boids.spvasm.snap index dd76914117..0736aad442 100644 --- a/tests/out/boids.spvasm.snap +++ b/tests/out/boids.spvasm.snap @@ -5,7 +5,7 @@ expression: dis ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 298 +; Bound: 286 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -25,44 +25,44 @@ OpName %26 "vel" OpName %27 "i" OpName %29 "main" OpName %36 "gl_GlobalInvocationID" -OpName %45 "Particle" -OpMemberName %45 0 "pos" -OpMemberName %45 1 "vel" -OpName %49 "Particles" -OpMemberName %49 0 "particles" -OpName %50 "particlesSrc" -OpName %121 "SimParams" -OpMemberName %121 0 "deltaT" -OpMemberName %121 1 "rule1Distance" -OpMemberName %121 2 "rule2Distance" -OpMemberName %121 3 "rule3Distance" -OpMemberName %121 4 "rule1Scale" -OpMemberName %121 5 "rule2Scale" -OpMemberName %121 6 "rule3Scale" -OpName %122 "params" -OpName %274 "particlesDst" +OpName %44 "Particle" +OpMemberName %44 0 "pos" +OpMemberName %44 1 "vel" +OpName %48 "Particles" +OpMemberName %48 0 "particles" +OpName %49 "particlesSrc" +OpName %118 "SimParams" +OpMemberName %118 0 "deltaT" +OpMemberName %118 1 "rule1Distance" +OpMemberName %118 2 "rule2Distance" +OpMemberName %118 3 "rule3Distance" +OpMemberName %118 4 "rule1Scale" +OpMemberName %118 5 "rule2Scale" +OpMemberName %118 6 "rule3Scale" +OpName %119 "params" +OpName %262 "particlesDst" OpName %29 "main" OpDecorate %36 BuiltIn GlobalInvocationId -OpMemberDecorate %45 0 Offset 0 -OpMemberDecorate %45 1 Offset 8 -OpDecorate %47 ArrayStride 16 -OpDecorate %49 BufferBlock -OpMemberDecorate %49 0 Offset 0 -OpDecorate %50 NonWritable -OpDecorate %50 DescriptorSet 0 -OpDecorate %50 Binding 1 -OpDecorate %121 Block -OpMemberDecorate %121 0 Offset 0 -OpMemberDecorate %121 1 Offset 4 -OpMemberDecorate %121 2 Offset 8 -OpMemberDecorate %121 3 Offset 12 -OpMemberDecorate %121 4 Offset 16 -OpMemberDecorate %121 5 Offset 20 -OpMemberDecorate %121 6 Offset 24 -OpDecorate %122 DescriptorSet 0 -OpDecorate %122 Binding 0 -OpDecorate %274 DescriptorSet 0 -OpDecorate %274 Binding 2 +OpMemberDecorate %44 0 Offset 0 +OpMemberDecorate %44 1 Offset 8 +OpDecorate %46 ArrayStride 16 +OpDecorate %48 BufferBlock +OpMemberDecorate %48 0 Offset 0 +OpDecorate %49 NonWritable +OpDecorate %49 DescriptorSet 0 +OpDecorate %49 Binding 1 +OpDecorate %118 Block +OpMemberDecorate %118 0 Offset 0 +OpMemberDecorate %118 1 Offset 4 +OpMemberDecorate %118 2 Offset 8 +OpMemberDecorate %118 3 Offset 12 +OpMemberDecorate %118 4 Offset 16 +OpMemberDecorate %118 5 Offset 20 +OpMemberDecorate %118 6 Offset 24 +OpDecorate %119 DescriptorSet 0 +OpDecorate %119 Binding 0 +OpDecorate %262 DescriptorSet 0 +OpDecorate %262 Binding 2 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpConstant %4 1500 @@ -87,85 +87,85 @@ OpDecorate %274 Binding 2 %36 = OpVariable %37 Input %38 = OpTypePointer Input %9 %39 = OpConstant %4 0 -%45 = OpTypeStruct %16 %16 -%47 = OpTypeRuntimeArray %45 -%49 = OpTypeStruct %47 -%51 = OpTypePointer Uniform %49 -%50 = OpVariable %51 Uniform -%52 = OpTypePointer Uniform %47 -%53 = OpConstant %4 0 -%55 = OpTypePointer Input %9 -%56 = OpConstant %4 0 -%58 = OpTypePointer Uniform %45 -%59 = OpTypePointer Uniform %16 -%60 = OpConstant %4 0 -%65 = OpTypePointer Uniform %47 -%66 = OpConstant %4 0 -%68 = OpTypePointer Input %9 -%69 = OpConstant %4 0 -%71 = OpTypePointer Uniform %45 -%72 = OpTypePointer Uniform %16 -%73 = OpConstant %4 1 -%90 = OpTypePointer Input %9 -%91 = OpConstant %4 0 -%99 = OpTypePointer Uniform %47 -%100 = OpConstant %4 0 -%102 = OpTypePointer Uniform %45 -%103 = OpTypePointer Uniform %16 -%104 = OpConstant %4 0 -%109 = OpTypePointer Uniform %47 -%110 = OpConstant %4 0 -%112 = OpTypePointer Uniform %45 -%113 = OpTypePointer Uniform %16 -%114 = OpConstant %4 1 -%121 = OpTypeStruct %6 %6 %6 %6 %6 %6 %6 -%123 = OpTypePointer Uniform %121 -%122 = OpVariable %123 Uniform -%124 = OpTypePointer Uniform %6 -%125 = OpConstant %4 1 -%140 = OpTypePointer Uniform %6 -%141 = OpConstant %4 2 -%156 = OpTypePointer Uniform %6 -%157 = OpConstant %4 3 -%198 = OpTypePointer Uniform %6 -%199 = OpConstant %4 4 -%204 = OpTypePointer Uniform %6 -%205 = OpConstant %4 5 -%210 = OpTypePointer Uniform %6 -%211 = OpConstant %4 6 -%224 = OpTypePointer Uniform %6 -%225 = OpConstant %4 0 -%229 = OpTypePointer Function %6 -%230 = OpConstant %4 0 -%236 = OpTypePointer Function %6 -%237 = OpConstant %4 0 -%240 = OpTypePointer Function %6 -%241 = OpConstant %4 0 +%44 = OpTypeStruct %16 %16 +%46 = OpTypeRuntimeArray %44 +%48 = OpTypeStruct %46 +%50 = OpTypePointer Uniform %48 +%49 = OpVariable %50 Uniform +%51 = OpTypePointer Uniform %46 +%52 = OpConstant %4 0 +%54 = OpTypePointer Input %9 +%55 = OpConstant %4 0 +%57 = OpTypePointer Uniform %44 +%58 = OpTypePointer Uniform %16 +%59 = OpConstant %4 0 +%64 = OpTypePointer Uniform %46 +%65 = OpConstant %4 0 +%67 = OpTypePointer Input %9 +%68 = OpConstant %4 0 +%70 = OpTypePointer Uniform %44 +%71 = OpTypePointer Uniform %16 +%72 = OpConstant %4 1 +%88 = OpTypePointer Input %9 +%89 = OpConstant %4 0 +%96 = OpTypePointer Uniform %46 +%97 = OpConstant %4 0 +%99 = OpTypePointer Uniform %44 +%100 = OpTypePointer Uniform %16 +%101 = OpConstant %4 0 +%106 = OpTypePointer Uniform %46 +%107 = OpConstant %4 0 +%109 = OpTypePointer Uniform %44 +%110 = OpTypePointer Uniform %16 +%111 = OpConstant %4 1 +%118 = OpTypeStruct %6 %6 %6 %6 %6 %6 %6 +%120 = OpTypePointer Uniform %118 +%119 = OpVariable %120 Uniform +%121 = OpTypePointer Uniform %6 +%122 = OpConstant %4 1 +%136 = OpTypePointer Uniform %6 +%137 = OpConstant %4 2 +%151 = OpTypePointer Uniform %6 +%152 = OpConstant %4 3 +%190 = OpTypePointer Uniform %6 +%191 = OpConstant %4 4 +%196 = OpTypePointer Uniform %6 +%197 = OpConstant %4 5 +%202 = OpTypePointer Uniform %6 +%203 = OpConstant %4 6 +%216 = OpTypePointer Uniform %6 +%217 = OpConstant %4 0 +%221 = OpTypePointer Function %6 +%222 = OpConstant %4 0 +%227 = OpTypePointer Function %6 +%228 = OpConstant %4 0 +%231 = OpTypePointer Function %6 +%232 = OpConstant %4 0 +%237 = OpTypePointer Function %6 +%238 = OpConstant %4 0 +%241 = OpTypePointer Function %6 +%242 = OpConstant %4 1 %247 = OpTypePointer Function %6 -%248 = OpConstant %4 0 +%248 = OpConstant %4 1 %251 = OpTypePointer Function %6 %252 = OpConstant %4 1 -%258 = OpTypePointer Function %6 -%259 = OpConstant %4 1 -%262 = OpTypePointer Function %6 -%263 = OpConstant %4 1 -%269 = OpTypePointer Function %6 -%270 = OpConstant %4 1 -%274 = OpVariable %51 Uniform -%275 = OpTypePointer Uniform %47 -%276 = OpConstant %4 0 -%278 = OpTypePointer Input %9 -%279 = OpConstant %4 0 -%281 = OpTypePointer Uniform %45 -%282 = OpTypePointer Uniform %16 -%283 = OpConstant %4 0 -%288 = OpTypePointer Uniform %47 -%289 = OpConstant %4 0 -%291 = OpTypePointer Input %9 -%292 = OpConstant %4 0 -%294 = OpTypePointer Uniform %45 -%295 = OpTypePointer Uniform %16 -%296 = OpConstant %4 1 +%257 = OpTypePointer Function %6 +%258 = OpConstant %4 1 +%262 = OpVariable %50 Uniform +%263 = OpTypePointer Uniform %46 +%264 = OpConstant %4 0 +%266 = OpTypePointer Input %9 +%267 = OpConstant %4 0 +%269 = OpTypePointer Uniform %44 +%270 = OpTypePointer Uniform %16 +%271 = OpConstant %4 0 +%276 = OpTypePointer Uniform %46 +%277 = OpConstant %4 0 +%279 = OpTypePointer Input %9 +%280 = OpConstant %4 0 +%282 = OpTypePointer Uniform %44 +%283 = OpTypePointer Uniform %16 +%284 = OpConstant %4 1 %29 = OpFunction %2 None %30 %31 = OpLabel %27 = OpVariable %28 Function %8 @@ -182,259 +182,235 @@ OpDecorate %274 Binding 2 %40 = OpLoad %9 %34 %33 = OpUGreaterThanEqual %32 %40 %3 OpSelectionMerge %41 None -OpBranchConditional %33 %42 %43 +OpBranchConditional %33 %42 %41 %42 = OpLabel OpReturn -%43 = OpLabel -OpBranch %41 %41 = OpLabel -%48 = OpAccessChain %52 %50 %53 -%54 = OpAccessChain %55 %36 %56 -%57 = OpLoad %9 %54 -%46 = OpAccessChain %58 %48 %57 -%44 = OpAccessChain %59 %46 %60 -%61 = OpLoad %16 %44 -OpStore %15 %61 -%64 = OpAccessChain %65 %50 %66 -%67 = OpAccessChain %68 %36 %69 -%70 = OpLoad %9 %67 -%63 = OpAccessChain %71 %64 %70 -%62 = OpAccessChain %72 %63 %73 -%74 = OpLoad %16 %62 -OpStore %18 %74 +%47 = OpAccessChain %51 %49 %52 +%53 = OpAccessChain %54 %36 %55 +%56 = OpLoad %9 %53 +%45 = OpAccessChain %57 %47 %56 +%43 = OpAccessChain %58 %45 %59 +%60 = OpLoad %16 %43 +OpStore %15 %60 +%63 = OpAccessChain %64 %49 %65 +%66 = OpAccessChain %67 %36 %68 +%69 = OpLoad %9 %66 +%62 = OpAccessChain %70 %63 %69 +%61 = OpAccessChain %71 %62 %72 +%73 = OpLoad %16 %61 +OpStore %18 %73 +%74 = OpCompositeConstruct %16 %5 %5 +OpStore %19 %74 %75 = OpCompositeConstruct %16 %5 %5 -OpStore %19 %75 +OpStore %20 %75 %76 = OpCompositeConstruct %16 %5 %5 -OpStore %20 %76 -%77 = OpCompositeConstruct %16 %5 %5 -OpStore %21 %77 +OpStore %21 %76 +OpBranch %77 +%77 = OpLabel +OpLoopMerge %78 %80 None +OpBranch %79 +%79 = OpLabel +%82 = OpLoad %9 %27 +%81 = OpUGreaterThanEqual %32 %82 %3 +OpSelectionMerge %83 None +OpBranchConditional %81 %84 %83 +%84 = OpLabel OpBranch %78 -%78 = OpLabel -OpLoopMerge %79 %81 None +%83 = OpLabel +%86 = OpLoad %9 %27 +%87 = OpAccessChain %88 %36 %89 +%90 = OpLoad %9 %87 +%85 = OpIEqual %32 %86 %90 +OpSelectionMerge %91 None +OpBranchConditional %85 %92 %91 +%92 = OpLabel +OpBranch %80 +%91 = OpLabel +%95 = OpAccessChain %96 %49 %97 +%98 = OpLoad %9 %27 +%94 = OpAccessChain %99 %95 %98 +%93 = OpAccessChain %100 %94 %101 +%102 = OpLoad %16 %93 +OpStore %25 %102 +%105 = OpAccessChain %106 %49 %107 +%108 = OpLoad %9 %27 +%104 = OpAccessChain %109 %105 %108 +%103 = OpAccessChain %110 %104 %111 +%112 = OpLoad %16 %103 +OpStore %26 %112 +%114 = OpLoad %16 %25 +%115 = OpLoad %16 %15 +%116 = OpExtInst %6 %1 Distance %114 %115 +%117 = OpAccessChain %121 %119 %122 +%123 = OpLoad %6 %117 +%113 = OpFOrdLessThan %32 %116 %123 +OpSelectionMerge %124 None +OpBranchConditional %113 %125 %124 +%125 = OpLabel +%127 = OpLoad %16 %19 +%128 = OpLoad %16 %25 +%126 = OpFAdd %16 %127 %128 +OpStore %19 %126 +%130 = OpLoad %4 %22 +%129 = OpIAdd %4 %130 %10 +OpStore %22 %129 +OpBranch %124 +%124 = OpLabel +%132 = OpLoad %16 %25 +%133 = OpLoad %16 %15 +%134 = OpExtInst %6 %1 Distance %132 %133 +%135 = OpAccessChain %136 %119 %137 +%138 = OpLoad %6 %135 +%131 = OpFOrdLessThan %32 %134 %138 +OpSelectionMerge %139 None +OpBranchConditional %131 %140 %139 +%140 = OpLabel +%142 = OpLoad %16 %21 +%144 = OpLoad %16 %25 +%145 = OpLoad %16 %15 +%143 = OpFSub %16 %144 %145 +%141 = OpFSub %16 %142 %143 +OpStore %21 %141 +OpBranch %139 +%139 = OpLabel +%147 = OpLoad %16 %25 +%148 = OpLoad %16 %15 +%149 = OpExtInst %6 %1 Distance %147 %148 +%150 = OpAccessChain %151 %119 %152 +%153 = OpLoad %6 %150 +%146 = OpFOrdLessThan %32 %149 %153 +OpSelectionMerge %154 None +OpBranchConditional %146 %155 %154 +%155 = OpLabel +%157 = OpLoad %16 %20 +%158 = OpLoad %16 %26 +%156 = OpFAdd %16 %157 %158 +OpStore %20 %156 +%160 = OpLoad %4 %24 +%159 = OpIAdd %4 %160 %10 +OpStore %24 %159 +OpBranch %154 +%154 = OpLabel OpBranch %80 %80 = OpLabel -%83 = OpLoad %9 %27 -%82 = OpUGreaterThanEqual %32 %83 %3 -OpSelectionMerge %84 None -OpBranchConditional %82 %85 %86 -%85 = OpLabel -OpBranch %79 -%86 = OpLabel -OpBranch %84 -%84 = OpLabel -%88 = OpLoad %9 %27 -%89 = OpAccessChain %90 %36 %91 -%92 = OpLoad %9 %89 -%87 = OpIEqual %32 %88 %92 -OpSelectionMerge %93 None -OpBranchConditional %87 %94 %95 -%94 = OpLabel -OpBranch %81 -%95 = OpLabel -OpBranch %93 -%93 = OpLabel -%98 = OpAccessChain %99 %50 %100 -%101 = OpLoad %9 %27 -%97 = OpAccessChain %102 %98 %101 -%96 = OpAccessChain %103 %97 %104 -%105 = OpLoad %16 %96 -OpStore %25 %105 -%108 = OpAccessChain %109 %50 %110 -%111 = OpLoad %9 %27 -%107 = OpAccessChain %112 %108 %111 -%106 = OpAccessChain %113 %107 %114 -%115 = OpLoad %16 %106 -OpStore %26 %115 -%117 = OpLoad %16 %25 -%118 = OpLoad %16 %15 -%119 = OpExtInst %6 %1 Distance %117 %118 -%120 = OpAccessChain %124 %122 %125 -%126 = OpLoad %6 %120 -%116 = OpFOrdLessThan %32 %119 %126 -OpSelectionMerge %127 None -OpBranchConditional %116 %128 %129 -%128 = OpLabel -%131 = OpLoad %16 %19 -%132 = OpLoad %16 %25 -%130 = OpFAdd %16 %131 %132 -OpStore %19 %130 -%134 = OpLoad %4 %22 -%133 = OpIAdd %4 %134 %10 -OpStore %22 %133 -OpBranch %127 -%129 = OpLabel -OpBranch %127 -%127 = OpLabel -%136 = OpLoad %16 %25 -%137 = OpLoad %16 %15 -%138 = OpExtInst %6 %1 Distance %136 %137 -%139 = OpAccessChain %140 %122 %141 -%142 = OpLoad %6 %139 -%135 = OpFOrdLessThan %32 %138 %142 -OpSelectionMerge %143 None -OpBranchConditional %135 %144 %145 -%144 = OpLabel -%147 = OpLoad %16 %21 -%149 = OpLoad %16 %25 -%150 = OpLoad %16 %15 -%148 = OpFSub %16 %149 %150 -%146 = OpFSub %16 %147 %148 -OpStore %21 %146 -OpBranch %143 -%145 = OpLabel -OpBranch %143 -%143 = OpLabel -%152 = OpLoad %16 %25 -%153 = OpLoad %16 %15 -%154 = OpExtInst %6 %1 Distance %152 %153 -%155 = OpAccessChain %156 %122 %157 -%158 = OpLoad %6 %155 -%151 = OpFOrdLessThan %32 %154 %158 -OpSelectionMerge %159 None -OpBranchConditional %151 %160 %161 -%160 = OpLabel -%163 = OpLoad %16 %20 -%164 = OpLoad %16 %26 -%162 = OpFAdd %16 %163 %164 -OpStore %20 %162 -%166 = OpLoad %4 %24 -%165 = OpIAdd %4 %166 %10 -OpStore %24 %165 -OpBranch %159 -%161 = OpLabel -OpBranch %159 -%159 = OpLabel -OpBranch %81 -%81 = OpLabel -%168 = OpLoad %9 %27 -%167 = OpIAdd %9 %168 %11 -OpStore %27 %167 -OpBranch %78 -%79 = OpLabel -%170 = OpLoad %4 %22 -%169 = OpSGreaterThan %32 %170 %7 -OpSelectionMerge %171 None -OpBranchConditional %169 %172 %173 -%172 = OpLabel -%176 = OpLoad %16 %19 -%178 = OpLoad %4 %22 -%179 = OpConvertSToF %6 %178 -%177 = OpFDiv %6 %12 %179 -%175 = OpVectorTimesScalar %16 %176 %177 -%180 = OpLoad %16 %15 -%174 = OpFSub %16 %175 %180 -OpStore %19 %174 -OpBranch %171 -%173 = OpLabel -OpBranch %171 -%171 = OpLabel -%182 = OpLoad %4 %24 -%181 = OpSGreaterThan %32 %182 %7 -OpSelectionMerge %183 None -OpBranchConditional %181 %184 %185 -%184 = OpLabel -%187 = OpLoad %16 %20 -%189 = OpLoad %4 %24 -%190 = OpConvertSToF %6 %189 -%188 = OpFDiv %6 %12 %190 -%186 = OpVectorTimesScalar %16 %187 %188 -OpStore %20 %186 -OpBranch %183 -%185 = OpLabel -OpBranch %183 -%183 = OpLabel -%194 = OpLoad %16 %18 -%196 = OpLoad %16 %19 -%197 = OpAccessChain %198 %122 %199 -%200 = OpLoad %6 %197 -%195 = OpVectorTimesScalar %16 %196 %200 -%193 = OpFAdd %16 %194 %195 -%202 = OpLoad %16 %21 -%203 = OpAccessChain %204 %122 %205 -%206 = OpLoad %6 %203 -%201 = OpVectorTimesScalar %16 %202 %206 -%192 = OpFAdd %16 %193 %201 -%208 = OpLoad %16 %20 -%209 = OpAccessChain %210 %122 %211 -%212 = OpLoad %6 %209 -%207 = OpVectorTimesScalar %16 %208 %212 -%191 = OpFAdd %16 %192 %207 -OpStore %18 %191 +%162 = OpLoad %9 %27 +%161 = OpIAdd %9 %162 %11 +OpStore %27 %161 +OpBranch %77 +%78 = OpLabel +%164 = OpLoad %4 %22 +%163 = OpSGreaterThan %32 %164 %7 +OpSelectionMerge %165 None +OpBranchConditional %163 %166 %165 +%166 = OpLabel +%169 = OpLoad %16 %19 +%171 = OpLoad %4 %22 +%172 = OpConvertSToF %6 %171 +%170 = OpFDiv %6 %12 %172 +%168 = OpVectorTimesScalar %16 %169 %170 +%173 = OpLoad %16 %15 +%167 = OpFSub %16 %168 %173 +OpStore %19 %167 +OpBranch %165 +%165 = OpLabel +%175 = OpLoad %4 %24 +%174 = OpSGreaterThan %32 %175 %7 +OpSelectionMerge %176 None +OpBranchConditional %174 %177 %176 +%177 = OpLabel +%179 = OpLoad %16 %20 +%181 = OpLoad %4 %24 +%182 = OpConvertSToF %6 %181 +%180 = OpFDiv %6 %12 %182 +%178 = OpVectorTimesScalar %16 %179 %180 +OpStore %20 %178 +OpBranch %176 +%176 = OpLabel +%186 = OpLoad %16 %18 +%188 = OpLoad %16 %19 +%189 = OpAccessChain %190 %119 %191 +%192 = OpLoad %6 %189 +%187 = OpVectorTimesScalar %16 %188 %192 +%185 = OpFAdd %16 %186 %187 +%194 = OpLoad %16 %21 +%195 = OpAccessChain %196 %119 %197 +%198 = OpLoad %6 %195 +%193 = OpVectorTimesScalar %16 %194 %198 +%184 = OpFAdd %16 %185 %193 +%200 = OpLoad %16 %20 +%201 = OpAccessChain %202 %119 %203 +%204 = OpLoad %6 %201 +%199 = OpVectorTimesScalar %16 %200 %204 +%183 = OpFAdd %16 %184 %199 +OpStore %18 %183 +%206 = OpLoad %16 %18 +%207 = OpExtInst %16 %1 Normalize %206 +%208 = OpLoad %16 %18 +%209 = OpExtInst %6 %1 Length %208 +%210 = OpExtInst %6 %1 FClamp %209 %5 %13 +%205 = OpVectorTimesScalar %16 %207 %210 +OpStore %18 %205 +%212 = OpLoad %16 %15 %214 = OpLoad %16 %18 -%215 = OpExtInst %16 %1 Normalize %214 -%216 = OpLoad %16 %18 -%217 = OpExtInst %6 %1 Length %216 -%218 = OpExtInst %6 %1 FClamp %217 %5 %13 -%213 = OpVectorTimesScalar %16 %215 %218 -OpStore %18 %213 -%220 = OpLoad %16 %15 -%222 = OpLoad %16 %18 -%223 = OpAccessChain %224 %122 %225 -%226 = OpLoad %6 %223 -%221 = OpVectorTimesScalar %16 %222 %226 -%219 = OpFAdd %16 %220 %221 -OpStore %15 %219 -%228 = OpAccessChain %229 %15 %230 -%231 = OpLoad %6 %228 -%227 = OpFOrdLessThan %32 %231 %14 -OpSelectionMerge %232 None -OpBranchConditional %227 %233 %234 -%233 = OpLabel -%235 = OpAccessChain %236 %15 %237 -OpStore %235 %12 -OpBranch %232 +%215 = OpAccessChain %216 %119 %217 +%218 = OpLoad %6 %215 +%213 = OpVectorTimesScalar %16 %214 %218 +%211 = OpFAdd %16 %212 %213 +OpStore %15 %211 +%220 = OpAccessChain %221 %15 %222 +%223 = OpLoad %6 %220 +%219 = OpFOrdLessThan %32 %223 %14 +OpSelectionMerge %224 None +OpBranchConditional %219 %225 %224 +%225 = OpLabel +%226 = OpAccessChain %227 %15 %228 +OpStore %226 %12 +OpBranch %224 +%224 = OpLabel +%230 = OpAccessChain %231 %15 %232 +%233 = OpLoad %6 %230 +%229 = OpFOrdGreaterThan %32 %233 %12 +OpSelectionMerge %234 None +OpBranchConditional %229 %235 %234 +%235 = OpLabel +%236 = OpAccessChain %237 %15 %238 +OpStore %236 %14 +OpBranch %234 %234 = OpLabel -OpBranch %232 -%232 = OpLabel -%239 = OpAccessChain %240 %15 %241 -%242 = OpLoad %6 %239 -%238 = OpFOrdGreaterThan %32 %242 %12 -OpSelectionMerge %243 None -OpBranchConditional %238 %244 %245 -%244 = OpLabel -%246 = OpAccessChain %247 %15 %248 -OpStore %246 %14 -OpBranch %243 +%240 = OpAccessChain %241 %15 %242 +%243 = OpLoad %6 %240 +%239 = OpFOrdLessThan %32 %243 %14 +OpSelectionMerge %244 None +OpBranchConditional %239 %245 %244 %245 = OpLabel -OpBranch %243 -%243 = OpLabel +%246 = OpAccessChain %247 %15 %248 +OpStore %246 %12 +OpBranch %244 +%244 = OpLabel %250 = OpAccessChain %251 %15 %252 %253 = OpLoad %6 %250 -%249 = OpFOrdLessThan %32 %253 %14 +%249 = OpFOrdGreaterThan %32 %253 %12 OpSelectionMerge %254 None -OpBranchConditional %249 %255 %256 +OpBranchConditional %249 %255 %254 %255 = OpLabel -%257 = OpAccessChain %258 %15 %259 -OpStore %257 %12 -OpBranch %254 -%256 = OpLabel +%256 = OpAccessChain %257 %15 %258 +OpStore %256 %14 OpBranch %254 %254 = OpLabel -%261 = OpAccessChain %262 %15 %263 -%264 = OpLoad %6 %261 -%260 = OpFOrdGreaterThan %32 %264 %12 -OpSelectionMerge %265 None -OpBranchConditional %260 %266 %267 -%266 = OpLabel -%268 = OpAccessChain %269 %15 %270 -OpStore %268 %14 -OpBranch %265 -%267 = OpLabel -OpBranch %265 -%265 = OpLabel -%273 = OpAccessChain %275 %274 %276 -%277 = OpAccessChain %278 %36 %279 -%280 = OpLoad %9 %277 -%272 = OpAccessChain %281 %273 %280 -%271 = OpAccessChain %282 %272 %283 -%284 = OpLoad %16 %15 -OpStore %271 %284 -%287 = OpAccessChain %288 %274 %289 -%290 = OpAccessChain %291 %36 %292 -%293 = OpLoad %9 %290 -%286 = OpAccessChain %294 %287 %293 -%285 = OpAccessChain %295 %286 %296 -%297 = OpLoad %16 %18 -OpStore %285 %297 +%261 = OpAccessChain %263 %262 %264 +%265 = OpAccessChain %266 %36 %267 +%268 = OpLoad %9 %265 +%260 = OpAccessChain %269 %261 %268 +%259 = OpAccessChain %270 %260 %271 +%272 = OpLoad %16 %15 +OpStore %259 %272 +%275 = OpAccessChain %276 %262 %277 +%278 = OpAccessChain %279 %36 %280 +%281 = OpLoad %9 %278 +%274 = OpAccessChain %282 %275 %281 +%273 = OpAccessChain %283 %274 %284 +%285 = OpLoad %16 %18 +OpStore %273 %285 OpReturn OpFunctionEnd diff --git a/tests/out/collatz.spvasm.snap b/tests/out/collatz.spvasm.snap index 8bdea00cd6..9817753c0e 100644 --- a/tests/out/collatz.spvasm.snap +++ b/tests/out/collatz.spvasm.snap @@ -5,28 +5,28 @@ expression: dis ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 70 +; Bound: 69 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %39 "main" %53 -OpExecutionMode %39 LocalSize 1 1 1 +OpEntryPoint GLCompute %38 "main" %52 +OpExecutionMode %38 LocalSize 1 1 1 OpSource GLSL 450 OpName %8 "n" OpName %10 "i" OpName %12 "collatz_iterations" -OpName %39 "main" -OpName %45 "PrimeIndices" -OpMemberName %45 0 "data" -OpName %46 "v_indices" -OpName %53 "global_id" -OpName %39 "main" -OpDecorate %43 ArrayStride 4 -OpDecorate %45 BufferBlock -OpMemberDecorate %45 0 Offset 0 -OpDecorate %46 DescriptorSet 0 -OpDecorate %46 Binding 0 -OpDecorate %53 BuiltIn GlobalInvocationId +OpName %38 "main" +OpName %44 "PrimeIndices" +OpMemberName %44 0 "data" +OpName %45 "v_indices" +OpName %52 "global_id" +OpName %38 "main" +OpDecorate %42 ArrayStride 4 +OpDecorate %44 BufferBlock +OpMemberDecorate %44 0 Offset 0 +OpDecorate %45 DescriptorSet 0 +OpDecorate %45 Binding 0 +OpDecorate %52 BuiltIn GlobalInvocationId %2 = OpTypeVoid %4 = OpTypeInt 32 0 %3 = OpConstant %4 0 @@ -36,25 +36,25 @@ OpDecorate %53 BuiltIn GlobalInvocationId %9 = OpTypePointer Function %4 %13 = OpTypeFunction %4 %4 %19 = OpTypeBool -%40 = OpTypeFunction %2 -%43 = OpTypeRuntimeArray %4 -%45 = OpTypeStruct %43 -%47 = OpTypePointer Uniform %45 -%46 = OpVariable %47 Uniform -%48 = OpTypePointer Uniform %43 -%49 = OpTypeInt 32 1 -%50 = OpConstant %49 0 -%52 = OpTypeVector %4 3 -%54 = OpTypePointer Input %52 -%53 = OpVariable %54 Input -%55 = OpTypePointer Input %4 -%56 = OpConstant %49 0 -%58 = OpTypePointer Uniform %4 -%62 = OpTypePointer Uniform %43 -%63 = OpConstant %49 0 -%65 = OpTypePointer Input %4 -%66 = OpConstant %49 0 -%68 = OpTypePointer Uniform %4 +%39 = OpTypeFunction %2 +%42 = OpTypeRuntimeArray %4 +%44 = OpTypeStruct %42 +%46 = OpTypePointer Uniform %44 +%45 = OpVariable %46 Uniform +%47 = OpTypePointer Uniform %42 +%48 = OpTypeInt 32 1 +%49 = OpConstant %48 0 +%51 = OpTypeVector %4 3 +%53 = OpTypePointer Input %51 +%52 = OpVariable %53 Input +%54 = OpTypePointer Input %4 +%55 = OpConstant %48 0 +%57 = OpTypePointer Uniform %4 +%61 = OpTypePointer Uniform %42 +%62 = OpConstant %48 0 +%64 = OpTypePointer Input %4 +%65 = OpConstant %48 0 +%67 = OpTypePointer Uniform %4 %12 = OpFunction %4 None %13 %11 = OpFunctionParameter %4 %14 = OpLabel @@ -69,51 +69,49 @@ OpBranch %17 %21 = OpLoad %4 %8 %20 = OpULessThanEqual %19 %21 %5 OpSelectionMerge %22 None -OpBranchConditional %20 %23 %24 +OpBranchConditional %20 %23 %22 %23 = OpLabel OpBranch %16 -%24 = OpLabel -OpBranch %22 %22 = OpLabel -%27 = OpLoad %4 %8 -%26 = OpUMod %4 %27 %6 -%25 = OpIEqual %19 %26 %3 -OpSelectionMerge %28 None -OpBranchConditional %25 %29 %30 -%29 = OpLabel -%32 = OpLoad %4 %8 -%31 = OpUDiv %4 %32 %6 -OpStore %8 %31 -OpBranch %28 -%30 = OpLabel -%35 = OpLoad %4 %8 -%34 = OpIMul %4 %7 %35 -%33 = OpIAdd %4 %34 %5 -OpStore %8 %33 -OpBranch %28 +%26 = OpLoad %4 %8 +%25 = OpUMod %4 %26 %6 +%24 = OpIEqual %19 %25 %3 +OpSelectionMerge %27 None +OpBranchConditional %24 %28 %29 %28 = OpLabel -%37 = OpLoad %4 %10 -%36 = OpIAdd %4 %37 %5 -OpStore %10 %36 +%31 = OpLoad %4 %8 +%30 = OpUDiv %4 %31 %6 +OpStore %8 %30 +OpBranch %27 +%29 = OpLabel +%34 = OpLoad %4 %8 +%33 = OpIMul %4 %7 %34 +%32 = OpIAdd %4 %33 %5 +OpStore %8 %32 +OpBranch %27 +%27 = OpLabel +%36 = OpLoad %4 %10 +%35 = OpIAdd %4 %36 %5 +OpStore %10 %35 OpBranch %18 %18 = OpLabel OpBranch %15 %16 = OpLabel -%38 = OpLoad %4 %10 -OpReturnValue %38 +%37 = OpLoad %4 %10 +OpReturnValue %37 OpFunctionEnd -%39 = OpFunction %2 None %40 -%41 = OpLabel -%44 = OpAccessChain %48 %46 %50 -%51 = OpAccessChain %55 %53 %56 -%57 = OpLoad %4 %51 -%42 = OpAccessChain %58 %44 %57 -%61 = OpAccessChain %62 %46 %63 -%64 = OpAccessChain %65 %53 %66 -%67 = OpLoad %4 %64 -%60 = OpAccessChain %68 %61 %67 -%69 = OpLoad %4 %60 -%59 = OpFunctionCall %4 %12 %69 -OpStore %42 %59 +%38 = OpFunction %2 None %39 +%40 = OpLabel +%43 = OpAccessChain %47 %45 %49 +%50 = OpAccessChain %54 %52 %55 +%56 = OpLoad %4 %50 +%41 = OpAccessChain %57 %43 %56 +%60 = OpAccessChain %61 %45 %62 +%63 = OpAccessChain %64 %52 %65 +%66 = OpLoad %4 %63 +%59 = OpAccessChain %67 %60 %66 +%68 = OpLoad %4 %59 +%58 = OpFunctionCall %4 %12 %68 +OpStore %41 %58 OpReturn OpFunctionEnd diff --git a/tests/out/shadow.spvasm.snap b/tests/out/shadow.spvasm.snap index cb7d42040a..75f9f7a81d 100644 --- a/tests/out/shadow.spvasm.snap +++ b/tests/out/shadow.spvasm.snap @@ -5,57 +5,57 @@ expression: dis ; SPIR-V ; Version: 1.2 ; Generator: rspirv -; Bound: 221 +; Bound: 219 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %64 "fs_main" %114 %111 %217 -OpExecutionMode %64 OriginUpperLeft +OpEntryPoint Fragment %63 "fs_main" %112 %109 %215 +OpExecutionMode %63 OriginUpperLeft OpSource GLSL 450 OpName %9 "c_ambient" OpName %11 "c_max_lights" OpName %18 "fetch_shadow" -OpName %28 "t_shadow" -OpName %33 "sampler_shadow" -OpName %60 "color" -OpName %62 "i" -OpName %64 "fs_main" -OpName %76 "Globals" -OpMemberName %76 0 "num_lights" -OpName %77 "u_globals" -OpName %97 "Light" -OpMemberName %97 0 "proj" -OpMemberName %97 1 "pos" -OpMemberName %97 2 "color" -OpName %101 "Lights" -OpMemberName %101 0 "data" -OpName %102 "s_lights" -OpName %111 "in_position_fs" -OpName %114 "in_normal_fs" -OpName %217 "out_color_fs" -OpName %64 "fs_main" -OpDecorate %28 DescriptorSet 0 -OpDecorate %28 Binding 2 -OpDecorate %33 DescriptorSet 0 -OpDecorate %33 Binding 3 -OpDecorate %76 Block -OpMemberDecorate %76 0 Offset 0 -OpDecorate %77 DescriptorSet 0 -OpDecorate %77 Binding 0 -OpMemberDecorate %97 0 Offset 0 -OpMemberDecorate %97 0 ColMajor -OpMemberDecorate %97 0 MatrixStride 16 -OpMemberDecorate %97 1 Offset 64 -OpMemberDecorate %97 2 Offset 80 -OpDecorate %99 ArrayStride 96 -OpDecorate %101 BufferBlock -OpMemberDecorate %101 0 Offset 0 -OpDecorate %102 NonWritable -OpDecorate %102 DescriptorSet 0 -OpDecorate %102 Binding 1 -OpDecorate %111 Location 1 -OpDecorate %114 Location 0 -OpDecorate %217 Location 0 +OpName %27 "t_shadow" +OpName %32 "sampler_shadow" +OpName %59 "color" +OpName %61 "i" +OpName %63 "fs_main" +OpName %75 "Globals" +OpMemberName %75 0 "num_lights" +OpName %76 "u_globals" +OpName %95 "Light" +OpMemberName %95 0 "proj" +OpMemberName %95 1 "pos" +OpMemberName %95 2 "color" +OpName %99 "Lights" +OpMemberName %99 0 "data" +OpName %100 "s_lights" +OpName %109 "in_position_fs" +OpName %112 "in_normal_fs" +OpName %215 "out_color_fs" +OpName %63 "fs_main" +OpDecorate %27 DescriptorSet 0 +OpDecorate %27 Binding 2 +OpDecorate %32 DescriptorSet 0 +OpDecorate %32 Binding 3 +OpDecorate %75 Block +OpMemberDecorate %75 0 Offset 0 +OpDecorate %76 DescriptorSet 0 +OpDecorate %76 Binding 0 +OpMemberDecorate %95 0 Offset 0 +OpMemberDecorate %95 0 ColMajor +OpMemberDecorate %95 0 MatrixStride 16 +OpMemberDecorate %95 1 Offset 64 +OpMemberDecorate %95 2 Offset 80 +OpDecorate %97 ArrayStride 96 +OpDecorate %99 BufferBlock +OpMemberDecorate %99 0 Offset 0 +OpDecorate %100 NonWritable +OpDecorate %100 DescriptorSet 0 +OpDecorate %100 Binding 1 +OpDecorate %109 Location 1 +OpDecorate %112 Location 0 +OpDecorate %215 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpConstant %4 0.0 @@ -72,92 +72,92 @@ OpDecorate %217 Location 0 %17 = OpTypeVector %4 4 %19 = OpTypeFunction %4 %12 %17 %21 = OpTypeBool -%27 = OpTypeImage %4 2D 1 1 0 1 Unknown -%29 = OpTypePointer UniformConstant %27 -%28 = OpVariable %29 UniformConstant -%31 = OpTypeSampledImage %27 -%32 = OpTypeSampler -%34 = OpTypePointer UniformConstant %32 -%33 = OpVariable %34 UniformConstant -%36 = OpTypeVector %4 2 -%50 = OpTypeInt 32 1 -%59 = OpConstant %4 0.0 -%61 = OpTypePointer Function %10 -%63 = OpTypePointer Function %12 -%65 = OpTypeFunction %2 -%74 = OpTypeVector %12 4 -%76 = OpTypeStruct %74 -%78 = OpTypePointer Uniform %76 -%77 = OpVariable %78 Uniform -%79 = OpTypePointer Uniform %74 -%80 = OpConstant %50 0 -%81 = OpTypePointer Uniform %12 -%82 = OpConstant %50 0 -%95 = OpTypeMatrix %17 4 -%97 = OpTypeStruct %95 %17 %17 -%99 = OpTypeRuntimeArray %97 -%101 = OpTypeStruct %99 -%103 = OpTypePointer Uniform %101 -%102 = OpVariable %103 Uniform -%104 = OpTypePointer Uniform %99 -%105 = OpConstant %50 0 -%107 = OpTypePointer Uniform %97 -%108 = OpTypePointer Uniform %95 -%109 = OpConstant %50 0 -%112 = OpTypePointer Input %17 -%111 = OpVariable %112 Input -%115 = OpTypePointer Input %10 -%114 = OpVariable %115 Input -%123 = OpTypePointer Uniform %99 -%124 = OpConstant %50 0 -%126 = OpTypePointer Uniform %97 -%127 = OpTypePointer Uniform %17 -%128 = OpConstant %50 1 -%129 = OpTypePointer Uniform %4 -%130 = OpConstant %50 0 -%136 = OpTypePointer Uniform %99 -%137 = OpConstant %50 0 -%139 = OpTypePointer Uniform %97 -%140 = OpTypePointer Uniform %17 -%141 = OpConstant %50 1 -%142 = OpTypePointer Uniform %4 -%143 = OpConstant %50 1 -%149 = OpTypePointer Uniform %99 -%150 = OpConstant %50 0 -%152 = OpTypePointer Uniform %97 -%153 = OpTypePointer Uniform %17 -%154 = OpConstant %50 1 -%155 = OpTypePointer Uniform %4 -%156 = OpConstant %50 2 -%160 = OpTypePointer Input %4 -%161 = OpConstant %50 0 -%164 = OpTypePointer Input %4 -%165 = OpConstant %50 1 -%168 = OpTypePointer Input %4 -%169 = OpConstant %50 2 -%179 = OpTypePointer Uniform %99 -%180 = OpConstant %50 0 -%182 = OpTypePointer Uniform %97 -%183 = OpTypePointer Uniform %17 -%184 = OpConstant %50 2 -%185 = OpTypePointer Uniform %4 -%186 = OpConstant %50 0 -%192 = OpTypePointer Uniform %99 -%193 = OpConstant %50 0 -%195 = OpTypePointer Uniform %97 -%196 = OpTypePointer Uniform %17 -%197 = OpConstant %50 2 -%198 = OpTypePointer Uniform %4 -%199 = OpConstant %50 1 -%205 = OpTypePointer Uniform %99 -%206 = OpConstant %50 0 -%208 = OpTypePointer Uniform %97 -%209 = OpTypePointer Uniform %17 -%210 = OpConstant %50 2 -%211 = OpTypePointer Uniform %4 -%212 = OpConstant %50 2 -%218 = OpTypePointer Output %17 -%217 = OpVariable %218 Output +%26 = OpTypeImage %4 2D 1 1 0 1 Unknown +%28 = OpTypePointer UniformConstant %26 +%27 = OpVariable %28 UniformConstant +%30 = OpTypeSampledImage %26 +%31 = OpTypeSampler +%33 = OpTypePointer UniformConstant %31 +%32 = OpVariable %33 UniformConstant +%35 = OpTypeVector %4 2 +%49 = OpTypeInt 32 1 +%58 = OpConstant %4 0.0 +%60 = OpTypePointer Function %10 +%62 = OpTypePointer Function %12 +%64 = OpTypeFunction %2 +%73 = OpTypeVector %12 4 +%75 = OpTypeStruct %73 +%77 = OpTypePointer Uniform %75 +%76 = OpVariable %77 Uniform +%78 = OpTypePointer Uniform %73 +%79 = OpConstant %49 0 +%80 = OpTypePointer Uniform %12 +%81 = OpConstant %49 0 +%93 = OpTypeMatrix %17 4 +%95 = OpTypeStruct %93 %17 %17 +%97 = OpTypeRuntimeArray %95 +%99 = OpTypeStruct %97 +%101 = OpTypePointer Uniform %99 +%100 = OpVariable %101 Uniform +%102 = OpTypePointer Uniform %97 +%103 = OpConstant %49 0 +%105 = OpTypePointer Uniform %95 +%106 = OpTypePointer Uniform %93 +%107 = OpConstant %49 0 +%110 = OpTypePointer Input %17 +%109 = OpVariable %110 Input +%113 = OpTypePointer Input %10 +%112 = OpVariable %113 Input +%121 = OpTypePointer Uniform %97 +%122 = OpConstant %49 0 +%124 = OpTypePointer Uniform %95 +%125 = OpTypePointer Uniform %17 +%126 = OpConstant %49 1 +%127 = OpTypePointer Uniform %4 +%128 = OpConstant %49 0 +%134 = OpTypePointer Uniform %97 +%135 = OpConstant %49 0 +%137 = OpTypePointer Uniform %95 +%138 = OpTypePointer Uniform %17 +%139 = OpConstant %49 1 +%140 = OpTypePointer Uniform %4 +%141 = OpConstant %49 1 +%147 = OpTypePointer Uniform %97 +%148 = OpConstant %49 0 +%150 = OpTypePointer Uniform %95 +%151 = OpTypePointer Uniform %17 +%152 = OpConstant %49 1 +%153 = OpTypePointer Uniform %4 +%154 = OpConstant %49 2 +%158 = OpTypePointer Input %4 +%159 = OpConstant %49 0 +%162 = OpTypePointer Input %4 +%163 = OpConstant %49 1 +%166 = OpTypePointer Input %4 +%167 = OpConstant %49 2 +%177 = OpTypePointer Uniform %97 +%178 = OpConstant %49 0 +%180 = OpTypePointer Uniform %95 +%181 = OpTypePointer Uniform %17 +%182 = OpConstant %49 2 +%183 = OpTypePointer Uniform %4 +%184 = OpConstant %49 0 +%190 = OpTypePointer Uniform %97 +%191 = OpConstant %49 0 +%193 = OpTypePointer Uniform %95 +%194 = OpTypePointer Uniform %17 +%195 = OpConstant %49 2 +%196 = OpTypePointer Uniform %4 +%197 = OpConstant %49 1 +%203 = OpTypePointer Uniform %97 +%204 = OpConstant %49 0 +%206 = OpTypePointer Uniform %95 +%207 = OpTypePointer Uniform %17 +%208 = OpConstant %49 2 +%209 = OpTypePointer Uniform %4 +%210 = OpConstant %49 2 +%216 = OpTypePointer Output %17 +%215 = OpVariable %216 Output %18 = OpFunction %4 None %19 %15 = OpFunctionParameter %12 %16 = OpFunctionParameter %17 @@ -165,133 +165,129 @@ OpDecorate %217 Location 0 %23 = OpCompositeExtract %4 %16 3 %22 = OpFOrdLessThanEqual %21 %23 %3 OpSelectionMerge %24 None -OpBranchConditional %22 %25 %26 +OpBranchConditional %22 %25 %24 %25 = OpLabel OpReturnValue %5 -%26 = OpLabel -OpBranch %24 %24 = OpLabel -%30 = OpLoad %27 %28 -%35 = OpLoad %32 %33 -%40 = OpCompositeExtract %4 %16 0 -%41 = OpCompositeExtract %4 %16 1 -%42 = OpCompositeConstruct %36 %40 %41 -%43 = OpCompositeConstruct %36 %6 %7 -%39 = OpFMul %36 %42 %43 -%45 = OpCompositeExtract %4 %16 3 -%44 = OpFDiv %4 %5 %45 -%38 = OpVectorTimesScalar %36 %39 %44 -%46 = OpCompositeConstruct %36 %6 %6 -%37 = OpFAdd %36 %38 %46 -%47 = OpCompositeExtract %4 %37 0 -%48 = OpCompositeExtract %4 %37 1 -%51 = OpBitcast %50 %15 -%49 = OpConvertUToF %4 %51 -%52 = OpCompositeConstruct %10 %47 %48 %49 -%53 = OpSampledImage %31 %30 %35 -%56 = OpCompositeExtract %4 %16 2 -%58 = OpCompositeExtract %4 %16 3 -%57 = OpFDiv %4 %5 %58 -%55 = OpFMul %4 %56 %57 -%54 = OpImageSampleDrefExplicitLod %4 %53 %52 %55 Lod %59 -OpReturnValue %54 +%29 = OpLoad %26 %27 +%34 = OpLoad %31 %32 +%39 = OpCompositeExtract %4 %16 0 +%40 = OpCompositeExtract %4 %16 1 +%41 = OpCompositeConstruct %35 %39 %40 +%42 = OpCompositeConstruct %35 %6 %7 +%38 = OpFMul %35 %41 %42 +%44 = OpCompositeExtract %4 %16 3 +%43 = OpFDiv %4 %5 %44 +%37 = OpVectorTimesScalar %35 %38 %43 +%45 = OpCompositeConstruct %35 %6 %6 +%36 = OpFAdd %35 %37 %45 +%46 = OpCompositeExtract %4 %36 0 +%47 = OpCompositeExtract %4 %36 1 +%50 = OpBitcast %49 %15 +%48 = OpConvertUToF %4 %50 +%51 = OpCompositeConstruct %10 %46 %47 %48 +%52 = OpSampledImage %30 %29 %34 +%55 = OpCompositeExtract %4 %16 2 +%57 = OpCompositeExtract %4 %16 3 +%56 = OpFDiv %4 %5 %57 +%54 = OpFMul %4 %55 %56 +%53 = OpImageSampleDrefExplicitLod %4 %52 %51 %54 Lod %58 +OpReturnValue %53 OpFunctionEnd -%64 = OpFunction %2 None %65 +%63 = OpFunction %2 None %64 +%65 = OpLabel +%59 = OpVariable %60 Function %9 +%61 = OpVariable %62 Function %13 +OpBranch %66 %66 = OpLabel -%60 = OpVariable %61 Function %9 -%62 = OpVariable %63 Function %13 +OpLoopMerge %67 %69 None +OpBranch %68 +%68 = OpLabel +%71 = OpLoad %12 %61 +%74 = OpAccessChain %78 %76 %79 +%72 = OpAccessChain %80 %74 %81 +%82 = OpLoad %12 %72 +%83 = OpExtInst %12 %1 UMin %82 %11 +%70 = OpUGreaterThanEqual %21 %71 %83 +OpSelectionMerge %84 None +OpBranchConditional %70 %85 %84 +%85 = OpLabel OpBranch %67 -%67 = OpLabel -OpLoopMerge %68 %70 None +%84 = OpLabel +%87 = OpLoad %10 %59 +%91 = OpLoad %12 %61 +%98 = OpAccessChain %102 %100 %103 +%104 = OpLoad %12 %61 +%96 = OpAccessChain %105 %98 %104 +%94 = OpAccessChain %106 %96 %107 +%108 = OpLoad %93 %94 +%111 = OpLoad %17 %109 +%92 = OpMatrixTimesVector %17 %108 %111 +%90 = OpFunctionCall %4 %18 %91 %92 +%114 = OpLoad %10 %112 +%115 = OpExtInst %10 %1 Normalize %114 +%120 = OpAccessChain %121 %100 %122 +%123 = OpLoad %12 %61 +%119 = OpAccessChain %124 %120 %123 +%118 = OpAccessChain %125 %119 %126 +%117 = OpAccessChain %127 %118 %128 +%129 = OpLoad %4 %117 +%133 = OpAccessChain %134 %100 %135 +%136 = OpLoad %12 %61 +%132 = OpAccessChain %137 %133 %136 +%131 = OpAccessChain %138 %132 %139 +%130 = OpAccessChain %140 %131 %141 +%142 = OpLoad %4 %130 +%146 = OpAccessChain %147 %100 %148 +%149 = OpLoad %12 %61 +%145 = OpAccessChain %150 %146 %149 +%144 = OpAccessChain %151 %145 %152 +%143 = OpAccessChain %153 %144 %154 +%155 = OpLoad %4 %143 +%156 = OpCompositeConstruct %10 %129 %142 %155 +%157 = OpAccessChain %158 %109 %159 +%160 = OpLoad %4 %157 +%161 = OpAccessChain %162 %109 %163 +%164 = OpLoad %4 %161 +%165 = OpAccessChain %166 %109 %167 +%168 = OpLoad %4 %165 +%169 = OpCompositeConstruct %10 %160 %164 %168 +%116 = OpFSub %10 %156 %169 +%170 = OpExtInst %10 %1 Normalize %116 +%171 = OpDot %4 %115 %170 +%172 = OpExtInst %4 %1 FMax %3 %171 +%89 = OpFMul %4 %90 %172 +%176 = OpAccessChain %177 %100 %178 +%179 = OpLoad %12 %61 +%175 = OpAccessChain %180 %176 %179 +%174 = OpAccessChain %181 %175 %182 +%173 = OpAccessChain %183 %174 %184 +%185 = OpLoad %4 %173 +%189 = OpAccessChain %190 %100 %191 +%192 = OpLoad %12 %61 +%188 = OpAccessChain %193 %189 %192 +%187 = OpAccessChain %194 %188 %195 +%186 = OpAccessChain %196 %187 %197 +%198 = OpLoad %4 %186 +%202 = OpAccessChain %203 %100 %204 +%205 = OpLoad %12 %61 +%201 = OpAccessChain %206 %202 %205 +%200 = OpAccessChain %207 %201 %208 +%199 = OpAccessChain %209 %200 %210 +%211 = OpLoad %4 %199 +%212 = OpCompositeConstruct %10 %185 %198 %211 +%88 = OpVectorTimesScalar %10 %212 %89 +%86 = OpFAdd %10 %87 %88 +OpStore %59 %86 OpBranch %69 %69 = OpLabel -%72 = OpLoad %12 %62 -%75 = OpAccessChain %79 %77 %80 -%73 = OpAccessChain %81 %75 %82 -%83 = OpLoad %12 %73 -%84 = OpExtInst %12 %1 UMin %83 %11 -%71 = OpUGreaterThanEqual %21 %72 %84 -OpSelectionMerge %85 None -OpBranchConditional %71 %86 %87 -%86 = OpLabel -OpBranch %68 -%87 = OpLabel -OpBranch %85 -%85 = OpLabel -%89 = OpLoad %10 %60 -%93 = OpLoad %12 %62 -%100 = OpAccessChain %104 %102 %105 -%106 = OpLoad %12 %62 -%98 = OpAccessChain %107 %100 %106 -%96 = OpAccessChain %108 %98 %109 -%110 = OpLoad %95 %96 -%113 = OpLoad %17 %111 -%94 = OpMatrixTimesVector %17 %110 %113 -%92 = OpFunctionCall %4 %18 %93 %94 -%116 = OpLoad %10 %114 -%117 = OpExtInst %10 %1 Normalize %116 -%122 = OpAccessChain %123 %102 %124 -%125 = OpLoad %12 %62 -%121 = OpAccessChain %126 %122 %125 -%120 = OpAccessChain %127 %121 %128 -%119 = OpAccessChain %129 %120 %130 -%131 = OpLoad %4 %119 -%135 = OpAccessChain %136 %102 %137 -%138 = OpLoad %12 %62 -%134 = OpAccessChain %139 %135 %138 -%133 = OpAccessChain %140 %134 %141 -%132 = OpAccessChain %142 %133 %143 -%144 = OpLoad %4 %132 -%148 = OpAccessChain %149 %102 %150 -%151 = OpLoad %12 %62 -%147 = OpAccessChain %152 %148 %151 -%146 = OpAccessChain %153 %147 %154 -%145 = OpAccessChain %155 %146 %156 -%157 = OpLoad %4 %145 -%158 = OpCompositeConstruct %10 %131 %144 %157 -%159 = OpAccessChain %160 %111 %161 -%162 = OpLoad %4 %159 -%163 = OpAccessChain %164 %111 %165 -%166 = OpLoad %4 %163 -%167 = OpAccessChain %168 %111 %169 -%170 = OpLoad %4 %167 -%171 = OpCompositeConstruct %10 %162 %166 %170 -%118 = OpFSub %10 %158 %171 -%172 = OpExtInst %10 %1 Normalize %118 -%173 = OpDot %4 %117 %172 -%174 = OpExtInst %4 %1 FMax %3 %173 -%91 = OpFMul %4 %92 %174 -%178 = OpAccessChain %179 %102 %180 -%181 = OpLoad %12 %62 -%177 = OpAccessChain %182 %178 %181 -%176 = OpAccessChain %183 %177 %184 -%175 = OpAccessChain %185 %176 %186 -%187 = OpLoad %4 %175 -%191 = OpAccessChain %192 %102 %193 -%194 = OpLoad %12 %62 -%190 = OpAccessChain %195 %191 %194 -%189 = OpAccessChain %196 %190 %197 -%188 = OpAccessChain %198 %189 %199 -%200 = OpLoad %4 %188 -%204 = OpAccessChain %205 %102 %206 -%207 = OpLoad %12 %62 -%203 = OpAccessChain %208 %204 %207 -%202 = OpAccessChain %209 %203 %210 -%201 = OpAccessChain %211 %202 %212 -%213 = OpLoad %4 %201 -%214 = OpCompositeConstruct %10 %187 %200 %213 -%90 = OpVectorTimesScalar %10 %214 %91 -%88 = OpFAdd %10 %89 %90 -OpStore %60 %88 -OpBranch %70 -%70 = OpLabel -%216 = OpLoad %12 %62 -%215 = OpIAdd %12 %216 %14 -OpStore %62 %215 -OpBranch %67 -%68 = OpLabel -%219 = OpLoad %10 %60 -%220 = OpCompositeConstruct %17 %219 %5 -OpStore %217 %220 +%214 = OpLoad %12 %61 +%213 = OpIAdd %12 %214 %14 +OpStore %61 %213 +OpBranch %66 +%67 = OpLabel +%217 = OpLoad %10 %59 +%218 = OpCompositeConstruct %17 %217 %5 +OpStore %215 %218 OpReturn OpFunctionEnd