-
Notifications
You must be signed in to change notification settings - Fork 664
spirv-opt: CCP pass might create a new constant and return SuccessWithoutChange #3636
Copy link
Copy link
Closed
Description
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main"
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeInt 32 1
%7 = OpConstant %6 2
%13 = OpConstant %6 4
%21 = OpConstant %6 1
%10 = OpTypeBool
%17 = OpTypePointer Function %6
%4 = OpFunction %2 None %3
%11 = OpLabel
OpBranch %5
%5 = OpLabel
%23 = OpPhi %6 %7 %11 %20 %15
%9 = OpSLessThan %10 %23 %13
OpLoopMerge %8 %15 None
OpBranchConditional %9 %15 %8
%15 = OpLabel
%20 = OpIAdd %6 %23 %21
OpBranch %5
%8 = OpLabel
OpReturn
OpFunctionEnd
The attached shader contains a SPIR-V that causes an assertion failure at
SPIRV-Tools/source/opt/optimizer.cpp
Lines 590 to 592 in b78f4b1
| assert(optimized_binary_with_nop.size() == original_binary_size && | |
| "Binary size unexpectedly changed despite the optimizer saying " | |
| "there was no change"); |
if the tool is executed with the following command spirv-opt <attached binary> -o out.spv --ccp (can be reproduced on b78f4b1).
The reason is that a new OpConstantTrue is created here
SPIRV-Tools/source/opt/ccp_pass.cpp
Lines 138 to 140 in b78f4b1
| Instruction* folded_inst = | |
| context()->get_instruction_folder().FoldInstructionToConstant(instr, | |
| map_func); |
when a CCP pass tries to fold an instruction with id
%9 for the first time. The second time the pass tries to simulate the execution of that instruction, it finds out that the instruction actually has a varying value, so the pass returns SuccessWithoutChange even though a new constant was created previously.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels