Files
wgpu/naga/tests/out/spv/operators.spvasm
Jim Blandy 3d85781f05 [naga spv-out] Consolidate code to find index values.
Let the SPIR-V backend use `GuardedIndex::try_resolve_to_constant`,
rather than writing out its definition in `write_restricted_index` and
`write_index_comparison`.

Call `try_resolve_to_constant` in one place, in `write_bounds_check`,
and simply pass the `GuardedIndex` into subroutines.

Reduce `write_restricted_index` and `write_index_comparison` to case
analysis and code generation.

Note that this commit does have a benign effect on SPIR-V snapshot
output for programs like this:

    let one_i = 1i;
    var vec0 = vec3<i32>();
    vec0[one_i] = 1;

The value indexing `vec0` here is an `i32`, but after this commit, the
operand to `OpAccessChain` becomes a `u32` constant (with the same
value).

This is because `write_bounds_check` now calls
`try_resolve_to_constant` itself, rather than deferring this work to
its callees, so it may return `BoundsCheckResult::KnownInBounds` even
when the `Unchecked` policy is in force. This directs the caller,
`write_expression_pointer`, to treat the `OpAccessChain` operand as a
fresh `u32` constant, rather than simply passing through the original
`i32` expression.
2024-10-08 11:53:15 -07:00

450 lines
13 KiB
Plaintext

; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 389
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %374 "main" %371
OpExecutionMode %374 LocalSize 1 1 1
OpDecorate %371 BuiltIn WorkgroupId
%2 = OpTypeVoid
%3 = OpTypeFloat 32
%4 = OpTypeVector %3 4
%5 = OpTypeInt 32 1
%6 = OpTypeVector %5 4
%8 = OpTypeBool
%7 = OpTypeVector %8 4
%9 = OpTypeVector %3 2
%10 = OpTypeVector %3 3
%11 = OpTypeMatrix %10 3
%12 = OpTypeMatrix %10 4
%13 = OpTypeMatrix %4 3
%14 = OpTypeVector %5 3
%16 = OpTypeInt 32 0
%15 = OpTypeVector %16 3
%17 = OpConstant %3 1.0
%18 = OpConstantComposite %4 %17 %17 %17 %17
%19 = OpConstant %3 0.0
%20 = OpConstantComposite %4 %19 %19 %19 %19
%21 = OpConstant %3 0.5
%22 = OpConstantComposite %4 %21 %21 %21 %21
%23 = OpConstant %5 1
%24 = OpConstantComposite %6 %23 %23 %23 %23
%27 = OpTypeFunction %4
%28 = OpConstantTrue %8
%29 = OpConstant %5 0
%30 = OpConstantFalse %8
%31 = OpConstantComposite %7 %30 %30 %30 %30
%32 = OpConstant %3 0.1
%33 = OpConstantComposite %6 %29 %29 %29 %29
%57 = OpTypeFunction %4 %3 %5
%58 = OpConstant %3 2.0
%59 = OpConstantComposite %9 %58 %58
%60 = OpConstant %3 4.0
%61 = OpConstantComposite %9 %60 %60
%62 = OpConstant %3 8.0
%63 = OpConstantComposite %9 %62 %62
%64 = OpConstant %5 2
%65 = OpConstantComposite %6 %64 %64 %64 %64
%78 = OpTypeFunction %9
%79 = OpConstantComposite %9 %17 %17
%80 = OpConstant %3 3.0
%81 = OpConstantComposite %9 %80 %80
%83 = OpTypePointer Function %9
%95 = OpTypeFunction %10 %10
%97 = OpTypeVector %8 3
%98 = OpConstantComposite %10 %19 %19 %19
%100 = OpConstantComposite %10 %17 %17 %17
%104 = OpTypeFunction %2
%105 = OpTypeVector %8 2
%106 = OpConstantComposite %105 %28 %28
%107 = OpConstantComposite %97 %28 %28 %28
%108 = OpConstantComposite %97 %30 %30 %30
%109 = OpConstantComposite %7 %28 %28 %28 %28
%110 = OpConstantComposite %7 %30 %30 %30 %30
%122 = OpConstant %16 1
%123 = OpConstant %16 2
%124 = OpTypeVector %5 2
%125 = OpConstantComposite %124 %23 %23
%126 = OpConstantComposite %124 %64 %64
%127 = OpConstantComposite %15 %123 %123 %123
%128 = OpConstantComposite %15 %122 %122 %122
%129 = OpConstantComposite %4 %58 %58 %58 %58
%130 = OpConstantComposite %4 %17 %17 %17 %17
%131 = OpTypeVector %16 2
%132 = OpConstantComposite %131 %123 %123
%133 = OpConstantComposite %131 %122 %122
%134 = OpConstantNull %11
%135 = OpConstantNull %12
%136 = OpConstantComposite %10 %58 %58 %58
%137 = OpConstantNull %13
%301 = OpConstantNull %14
%303 = OpTypePointer Function %5
%304 = OpConstantNull %5
%306 = OpTypePointer Function %14
%334 = OpTypePointer Function %5
%372 = OpTypePointer Input %15
%371 = OpVariable %372 Input
%375 = OpConstantComposite %10 %17 %17 %17
%26 = OpFunction %4 None %27
%25 = OpLabel
OpBranch %34
%34 = OpLabel
%35 = OpSelect %5 %28 %23 %29
%37 = OpCompositeConstruct %7 %28 %28 %28 %28
%36 = OpSelect %4 %37 %18 %20
%38 = OpSelect %4 %31 %20 %18
%39 = OpExtInst %4 %1 FMix %20 %18 %22
%41 = OpCompositeConstruct %4 %32 %32 %32 %32
%40 = OpExtInst %4 %1 FMix %20 %18 %41
%42 = OpBitcast %3 %23
%43 = OpBitcast %4 %24
%44 = OpCompositeConstruct %6 %35 %35 %35 %35
%45 = OpIAdd %6 %44 %33
%46 = OpConvertSToF %4 %45
%47 = OpFAdd %4 %46 %36
%48 = OpFAdd %4 %47 %39
%49 = OpFAdd %4 %48 %40
%50 = OpCompositeConstruct %4 %42 %42 %42 %42
%51 = OpFAdd %4 %49 %50
%52 = OpFAdd %4 %51 %43
OpReturnValue %52
OpFunctionEnd
%56 = OpFunction %4 None %57
%54 = OpFunctionParameter %3
%55 = OpFunctionParameter %5
%53 = OpLabel
OpBranch %66
%66 = OpLabel
%67 = OpCompositeConstruct %9 %54 %54
%68 = OpFAdd %9 %59 %67
%69 = OpFSub %9 %68 %61
%70 = OpFDiv %9 %69 %63
%71 = OpCompositeConstruct %6 %55 %55 %55 %55
%72 = OpSRem %6 %71 %65
%73 = OpVectorShuffle %4 %70 %70 0 1 0 1
%74 = OpConvertSToF %4 %72
%75 = OpFAdd %4 %73 %74
OpReturnValue %75
OpFunctionEnd
%77 = OpFunction %9 None %78
%76 = OpLabel
%82 = OpVariable %83 Function %59
OpBranch %84
%84 = OpLabel
%85 = OpLoad %9 %82
%86 = OpFAdd %9 %85 %79
OpStore %82 %86
%87 = OpLoad %9 %82
%88 = OpFSub %9 %87 %81
OpStore %82 %88
%89 = OpLoad %9 %82
%90 = OpFDiv %9 %89 %61
OpStore %82 %90
%91 = OpLoad %9 %82
OpReturnValue %91
OpFunctionEnd
%94 = OpFunction %10 None %95
%93 = OpFunctionParameter %10
%92 = OpLabel
OpBranch %96
%96 = OpLabel
%99 = OpFUnordNotEqual %97 %93 %98
%101 = OpSelect %10 %99 %100 %98
OpReturnValue %101
OpFunctionEnd
%103 = OpFunction %2 None %104
%102 = OpLabel
OpBranch %111
%111 = OpLabel
%112 = OpLogicalNot %8 %28
%113 = OpLogicalNot %105 %106
%114 = OpLogicalOr %8 %28 %30
%115 = OpLogicalAnd %8 %28 %30
%116 = OpLogicalOr %8 %28 %30
%117 = OpLogicalOr %97 %107 %108
%118 = OpLogicalAnd %8 %28 %30
%119 = OpLogicalAnd %7 %109 %110
OpReturn
OpFunctionEnd
%121 = OpFunction %2 None %104
%120 = OpLabel
OpBranch %138
%138 = OpLabel
%139 = OpFNegate %3 %17
%140 = OpSNegate %124 %125
%141 = OpFNegate %9 %79
%142 = OpIAdd %5 %64 %23
%143 = OpIAdd %16 %123 %122
%144 = OpFAdd %3 %58 %17
%145 = OpIAdd %124 %126 %125
%146 = OpIAdd %15 %127 %128
%147 = OpFAdd %4 %129 %130
%148 = OpISub %5 %64 %23
%149 = OpISub %16 %123 %122
%150 = OpFSub %3 %58 %17
%151 = OpISub %124 %126 %125
%152 = OpISub %15 %127 %128
%153 = OpFSub %4 %129 %130
%154 = OpIMul %5 %64 %23
%155 = OpIMul %16 %123 %122
%156 = OpFMul %3 %58 %17
%157 = OpIMul %124 %126 %125
%158 = OpIMul %15 %127 %128
%159 = OpFMul %4 %129 %130
%160 = OpSDiv %5 %64 %23
%161 = OpUDiv %16 %123 %122
%162 = OpFDiv %3 %58 %17
%163 = OpSDiv %124 %126 %125
%164 = OpUDiv %15 %127 %128
%165 = OpFDiv %4 %129 %130
%166 = OpSRem %5 %64 %23
%167 = OpUMod %16 %123 %122
%168 = OpFRem %3 %58 %17
%169 = OpSRem %124 %126 %125
%170 = OpUMod %15 %127 %128
%171 = OpFRem %4 %129 %130
OpBranch %172
%172 = OpLabel
%174 = OpIAdd %124 %126 %125
%175 = OpIAdd %124 %126 %125
%176 = OpIAdd %131 %132 %133
%177 = OpIAdd %131 %132 %133
%178 = OpFAdd %9 %59 %79
%179 = OpFAdd %9 %59 %79
%180 = OpISub %124 %126 %125
%181 = OpISub %124 %126 %125
%182 = OpISub %131 %132 %133
%183 = OpISub %131 %132 %133
%184 = OpFSub %9 %59 %79
%185 = OpFSub %9 %59 %79
%187 = OpCompositeConstruct %124 %23 %23
%186 = OpIMul %124 %126 %187
%189 = OpCompositeConstruct %124 %64 %64
%188 = OpIMul %124 %125 %189
%191 = OpCompositeConstruct %131 %122 %122
%190 = OpIMul %131 %132 %191
%193 = OpCompositeConstruct %131 %123 %123
%192 = OpIMul %131 %133 %193
%194 = OpVectorTimesScalar %9 %59 %17
%195 = OpVectorTimesScalar %9 %79 %58
%196 = OpSDiv %124 %126 %125
%197 = OpSDiv %124 %126 %125
%198 = OpUDiv %131 %132 %133
%199 = OpUDiv %131 %132 %133
%200 = OpFDiv %9 %59 %79
%201 = OpFDiv %9 %59 %79
%202 = OpSRem %124 %126 %125
%203 = OpSRem %124 %126 %125
%204 = OpUMod %131 %132 %133
%205 = OpUMod %131 %132 %133
%206 = OpFRem %9 %59 %79
%207 = OpFRem %9 %59 %79
OpBranch %173
%173 = OpLabel
%209 = OpCompositeExtract %10 %134 0
%210 = OpCompositeExtract %10 %134 0
%211 = OpFAdd %10 %209 %210
%212 = OpCompositeExtract %10 %134 1
%213 = OpCompositeExtract %10 %134 1
%214 = OpFAdd %10 %212 %213
%215 = OpCompositeExtract %10 %134 2
%216 = OpCompositeExtract %10 %134 2
%217 = OpFAdd %10 %215 %216
%208 = OpCompositeConstruct %11 %211 %214 %217
%219 = OpCompositeExtract %10 %134 0
%220 = OpCompositeExtract %10 %134 0
%221 = OpFSub %10 %219 %220
%222 = OpCompositeExtract %10 %134 1
%223 = OpCompositeExtract %10 %134 1
%224 = OpFSub %10 %222 %223
%225 = OpCompositeExtract %10 %134 2
%226 = OpCompositeExtract %10 %134 2
%227 = OpFSub %10 %225 %226
%218 = OpCompositeConstruct %11 %221 %224 %227
%228 = OpMatrixTimesScalar %11 %134 %17
%229 = OpMatrixTimesScalar %11 %134 %58
%230 = OpMatrixTimesVector %10 %135 %130
%231 = OpVectorTimesMatrix %4 %136 %135
%232 = OpMatrixTimesMatrix %11 %135 %137
OpReturn
OpFunctionEnd
%234 = OpFunction %2 None %104
%233 = OpLabel
OpBranch %235
%235 = OpLabel
%236 = OpNot %5 %23
%237 = OpNot %16 %122
%238 = OpNot %124 %125
%239 = OpNot %15 %128
%240 = OpBitwiseOr %5 %64 %23
%241 = OpBitwiseOr %16 %123 %122
%242 = OpBitwiseOr %124 %126 %125
%243 = OpBitwiseOr %15 %127 %128
%244 = OpBitwiseAnd %5 %64 %23
%245 = OpBitwiseAnd %16 %123 %122
%246 = OpBitwiseAnd %124 %126 %125
%247 = OpBitwiseAnd %15 %127 %128
%248 = OpBitwiseXor %5 %64 %23
%249 = OpBitwiseXor %16 %123 %122
%250 = OpBitwiseXor %124 %126 %125
%251 = OpBitwiseXor %15 %127 %128
%252 = OpShiftLeftLogical %5 %64 %122
%253 = OpShiftLeftLogical %16 %123 %122
%254 = OpShiftLeftLogical %124 %126 %133
%255 = OpShiftLeftLogical %15 %127 %128
%256 = OpShiftRightArithmetic %5 %64 %122
%257 = OpShiftRightLogical %16 %123 %122
%258 = OpShiftRightArithmetic %124 %126 %133
%259 = OpShiftRightLogical %15 %127 %128
OpReturn
OpFunctionEnd
%261 = OpFunction %2 None %104
%260 = OpLabel
OpBranch %262
%262 = OpLabel
%263 = OpIEqual %8 %64 %23
%264 = OpIEqual %8 %123 %122
%265 = OpFOrdEqual %8 %58 %17
%266 = OpIEqual %105 %126 %125
%267 = OpIEqual %97 %127 %128
%268 = OpFOrdEqual %7 %129 %130
%269 = OpINotEqual %8 %64 %23
%270 = OpINotEqual %8 %123 %122
%271 = OpFOrdNotEqual %8 %58 %17
%272 = OpINotEqual %105 %126 %125
%273 = OpINotEqual %97 %127 %128
%274 = OpFOrdNotEqual %7 %129 %130
%275 = OpSLessThan %8 %64 %23
%276 = OpULessThan %8 %123 %122
%277 = OpFOrdLessThan %8 %58 %17
%278 = OpSLessThan %105 %126 %125
%279 = OpULessThan %97 %127 %128
%280 = OpFOrdLessThan %7 %129 %130
%281 = OpSLessThanEqual %8 %64 %23
%282 = OpULessThanEqual %8 %123 %122
%283 = OpFOrdLessThanEqual %8 %58 %17
%284 = OpSLessThanEqual %105 %126 %125
%285 = OpULessThanEqual %97 %127 %128
%286 = OpFOrdLessThanEqual %7 %129 %130
%287 = OpSGreaterThan %8 %64 %23
%288 = OpUGreaterThan %8 %123 %122
%289 = OpFOrdGreaterThan %8 %58 %17
%290 = OpSGreaterThan %105 %126 %125
%291 = OpUGreaterThan %97 %127 %128
%292 = OpFOrdGreaterThan %7 %129 %130
%293 = OpSGreaterThanEqual %8 %64 %23
%294 = OpUGreaterThanEqual %8 %123 %122
%295 = OpFOrdGreaterThanEqual %8 %58 %17
%296 = OpSGreaterThanEqual %105 %126 %125
%297 = OpUGreaterThanEqual %97 %127 %128
%298 = OpFOrdGreaterThanEqual %7 %129 %130
OpReturn
OpFunctionEnd
%300 = OpFunction %2 None %104
%299 = OpLabel
%302 = OpVariable %303 Function %304
%305 = OpVariable %306 Function %301
OpBranch %307
%307 = OpLabel
OpStore %302 %23
%308 = OpLoad %5 %302
%309 = OpIAdd %5 %308 %23
OpStore %302 %309
%310 = OpLoad %5 %302
%311 = OpISub %5 %310 %23
OpStore %302 %311
%312 = OpLoad %5 %302
%313 = OpLoad %5 %302
%314 = OpIMul %5 %313 %312
OpStore %302 %314
%315 = OpLoad %5 %302
%316 = OpLoad %5 %302
%317 = OpSDiv %5 %316 %315
OpStore %302 %317
%318 = OpLoad %5 %302
%319 = OpSRem %5 %318 %23
OpStore %302 %319
%320 = OpLoad %5 %302
%321 = OpBitwiseAnd %5 %320 %29
OpStore %302 %321
%322 = OpLoad %5 %302
%323 = OpBitwiseOr %5 %322 %29
OpStore %302 %323
%324 = OpLoad %5 %302
%325 = OpBitwiseXor %5 %324 %29
OpStore %302 %325
%326 = OpLoad %5 %302
%327 = OpShiftLeftLogical %5 %326 %123
OpStore %302 %327
%328 = OpLoad %5 %302
%329 = OpShiftRightArithmetic %5 %328 %122
OpStore %302 %329
%330 = OpLoad %5 %302
%331 = OpIAdd %5 %330 %23
OpStore %302 %331
%332 = OpLoad %5 %302
%333 = OpISub %5 %332 %23
OpStore %302 %333
%335 = OpAccessChain %334 %305 %122
%336 = OpLoad %5 %335
%337 = OpIAdd %5 %336 %23
%338 = OpAccessChain %334 %305 %122
OpStore %338 %337
%339 = OpAccessChain %334 %305 %122
%340 = OpLoad %5 %339
%341 = OpISub %5 %340 %23
%342 = OpAccessChain %334 %305 %122
OpStore %342 %341
OpReturn
OpFunctionEnd
%344 = OpFunction %2 None %104
%343 = OpLabel
OpBranch %345
%345 = OpLabel
%346 = OpSNegate %5 %23
%347 = OpSNegate %5 %23
%348 = OpSNegate %5 %347
%349 = OpSNegate %5 %23
%350 = OpSNegate %5 %349
%351 = OpSNegate %5 %23
%352 = OpSNegate %5 %351
%353 = OpSNegate %5 %23
%354 = OpSNegate %5 %353
%355 = OpSNegate %5 %354
%356 = OpSNegate %5 %23
%357 = OpSNegate %5 %356
%358 = OpSNegate %5 %357
%359 = OpSNegate %5 %358
%360 = OpSNegate %5 %23
%361 = OpSNegate %5 %360
%362 = OpSNegate %5 %361
%363 = OpSNegate %5 %362
%364 = OpSNegate %5 %363
%365 = OpSNegate %5 %23
%366 = OpSNegate %5 %365
%367 = OpSNegate %5 %366
%368 = OpSNegate %5 %367
%369 = OpSNegate %5 %368
OpReturn
OpFunctionEnd
%374 = OpFunction %2 None %104
%370 = OpLabel
%373 = OpLoad %15 %371
OpBranch %376
%376 = OpLabel
%377 = OpFunctionCall %4 %26
%378 = OpCompositeExtract %16 %373 0
%379 = OpConvertUToF %3 %378
%380 = OpCompositeExtract %16 %373 1
%381 = OpBitcast %5 %380
%382 = OpFunctionCall %4 %56 %379 %381
%383 = OpFunctionCall %10 %94 %375
%384 = OpFunctionCall %2 %103
%385 = OpFunctionCall %2 %121
%386 = OpFunctionCall %2 %234
%387 = OpFunctionCall %2 %261
%388 = OpFunctionCall %2 %300
OpReturn
OpFunctionEnd