mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-23 07:20:28 +00:00
spirv-opt: skips if_conversion when dontflatten is set (#4770)
This commit is contained in:
parent
671f6e633f
commit
46492aa45a
@ -169,6 +169,8 @@ bool IfConversion::CheckBlock(BasicBlock* block, DominatorAnalysis* dominators,
|
||||
if (branch->opcode() != SpvOpBranchConditional) return false;
|
||||
auto merge = (*common)->GetMergeInst();
|
||||
if (!merge || merge->opcode() != SpvOpSelectionMerge) return false;
|
||||
if (merge->GetSingleWordInOperand(1) == SpvSelectionControlDontFlattenMask)
|
||||
return false;
|
||||
if ((*common)->MergeBlockIdIfAny() != block->id()) return false;
|
||||
|
||||
return true;
|
||||
|
@ -328,6 +328,40 @@ OpFunctionEnd
|
||||
SinglePassRunAndCheck<IfConversion>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, DontFlatten) {
|
||||
const std::string text = R"(OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Vertex %1 "func" %2
|
||||
%void = OpTypeVoid
|
||||
%bool = OpTypeBool
|
||||
%true = OpConstantTrue %bool
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%v2uint = OpTypeVector %uint 2
|
||||
%10 = OpConstantComposite %v2uint %uint_0 %uint_1
|
||||
%11 = OpConstantComposite %v2uint %uint_1 %uint_0
|
||||
%_ptr_Output_v2uint = OpTypePointer Output %v2uint
|
||||
%2 = OpVariable %_ptr_Output_v2uint Output
|
||||
%13 = OpTypeFunction %void
|
||||
%1 = OpFunction %void None %13
|
||||
%14 = OpLabel
|
||||
OpSelectionMerge %15 DontFlatten
|
||||
OpBranchConditional %true %16 %17
|
||||
%16 = OpLabel
|
||||
OpBranch %15
|
||||
%17 = OpLabel
|
||||
OpBranch %15
|
||||
%15 = OpLabel
|
||||
%18 = OpPhi %v2uint %10 %16 %11 %17
|
||||
OpStore %2 %18
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<IfConversion>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, LoopUntouched) {
|
||||
const std::string text = R"(OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
Loading…
Reference in New Issue
Block a user