-
Notifications
You must be signed in to change notification settings - Fork 664
spirv-opt: CCP pass still changes the module and returns SuccessWithoutChange #3738
Description
The following shader
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main"
OpExecutionMode %4 OriginUpperLeft
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%8 = OpTypeFloat 32
%12 = OpTypeVector %8 3
%87 = OpTypeInt 32 0
%88 = OpConstant %87 0
%153 = OpTypeBool
%154 = OpTypeVector %153 3
%398 = OpConstant %8 0
%399 = OpConstantComposite %12 %398 %398 %398
%533 = OpConstant %8 0.300000012
%534 = OpConstantComposite %12 %533 %533 %533
%4 = OpFunction %2 None %3
%5 = OpLabel
OpBranch %2209
%2209 = OpLabel
%3155 = OpPhi %12 %399 %5 %534 %2272
%3246 = OpFOrdLessThan %154 %3155 %534
%3247 = OpAll %153 %3246
OpLoopMerge %2275 %2272 None
OpBranchConditional %3247 %2272 %2275
%2272 = OpLabel
OpBranch %2209
%2275 = OpLabel
%535 = OpExtInst %12 %1 FMix %399 %3155 %534
OpReturn
OpFunctionEnd
produces an error
spirv-opt: /home/vasniktel/gsoc/spirv-repo/source/opt/optimizer.cpp:592: bool spvtools::Optimizer::Run(const uint32_t *, const size_t, std::vector<uint32_t> *, const spv_optimizer_options) const: Assertion `optimized_binary_with_nop.size() == original_binary_size && "Binary size unexpectedly changed despite the optimizer saying " "there was no change"' failed.
when executed with spirv-opt <compiled binary> -o out.spv --ccp --validate-after-all.
Can be reproduced on 4dd1223.
The situation is similar to #3636 except that the created constant is not returned and instead used internally by the folder. In this particular example, the folder creates a constant 1 and 1 - %534 (this is required by the OpFMix instruction).