Skip structurize when only 1 ret. (#3754)
This commit is contained in:
Родитель
254af3a55a
Коммит
2298848552
|
@ -3149,7 +3149,7 @@ ScopeInfo::ScopeInfo(Function *F) : maxRetLevel(0), bAllReturnsInIf(true) {
|
|||
// When all returns is inside if which is not nested, the flow is still
|
||||
// structurized even there're more than one return.
|
||||
bool ScopeInfo::CanSkipStructurize() {
|
||||
return bAllReturnsInIf && maxRetLevel < 2;
|
||||
return (bAllReturnsInIf && maxRetLevel < 2) || rets.size() < 2;
|
||||
}
|
||||
|
||||
void ScopeInfo::AddScope(Scope::ScopeKind k, BasicBlock *endScopeBB) {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// RUN: %dxc -Emain -opt-enable structurize-returns -Tps_6_0 %s | FileCheck %s
|
||||
|
||||
// Make sure not crash.
|
||||
// CHECK:call %dx.types.ResRet.i32 @dx.op.bufferLoad
|
||||
|
||||
struct ST
|
||||
{
|
||||
uint a;
|
||||
};
|
||||
|
||||
|
||||
StructuredBuffer<ST> buf;
|
||||
|
||||
uint main(uint i:I) : SV_Target {
|
||||
for(;;)
|
||||
{
|
||||
if(i<buf[i].a)
|
||||
i++;
|
||||
else
|
||||
return buf[i].a;
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче