mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2025-01-12 09:20:15 +00:00
Removing decorations when doing constant propagation. (#2444)
In constant propagation, decoration are transfered from the original expression to the constant that will replace it. This can be wrong because there are no decorations that apply to constants. We choose to simply delete the decorations. Fixes #2441
This commit is contained in:
parent
b75f4362f0
commit
9d29c37ac5
@ -271,6 +271,7 @@ bool CCPPass::ReplaceValues() {
|
||||
uint32_t id = it.first;
|
||||
uint32_t cst_id = it.second;
|
||||
if (!IsVaryingValue(cst_id) && id != cst_id) {
|
||||
context()->KillNamesAndDecorates(id);
|
||||
retval |= context()->ReplaceAllUsesWith(id, cst_id);
|
||||
}
|
||||
}
|
||||
|
@ -896,6 +896,35 @@ OpFunctionEnd
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, FoldWithDecoration) {
|
||||
const std::string text = R"(
|
||||
; CHECK: OpCapability
|
||||
; CHECK-NOT: OpDecorate
|
||||
; CHECK: OpFunctionEnd
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %2 "main"
|
||||
OpExecutionMode %2 OriginUpperLeft
|
||||
OpSource ESSL 310
|
||||
OpDecorate %3 RelaxedPrecision
|
||||
%void = OpTypeVoid
|
||||
%5 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v3float = OpTypeVector %float 3
|
||||
%float_0 = OpConstant %float 0
|
||||
%v4float = OpTypeVector %float 4
|
||||
%10 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
|
||||
%2 = OpFunction %void None %5
|
||||
%11 = OpLabel
|
||||
%3 = OpVectorShuffle %v3float %10 %10 0 1 2
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
Loading…
Reference in New Issue
Block a user