Improve dead-code elimination check in SPIR-V.
The dead-code elimination pass only occurs when three separate flags are all enabled: optimize, control-flow analysis, dead-code elimination. Previously the code checked just the dead-code elimination flag, not the other two. Change-Id: I1e7e356432c4398f6b072d472fe4d1ec5dac107e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376178 Auto-Submit: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
34c7e11492
commit
453f143dba
@ -236,18 +236,21 @@ void SPIRVCodeGenerator::writeOpCode(SpvOp_ opCode, int length, OutputStream& ou
|
||||
case SpvOpMemberDecorate:
|
||||
break;
|
||||
default:
|
||||
if (!fProgram.fConfig->fSettings.fDeadCodeElimination) {
|
||||
if (fProgram.fConfig->fSettings.fOptimize &&
|
||||
fProgram.fConfig->fSettings.fControlFlowAnalysis &&
|
||||
fProgram.fConfig->fSettings.fDeadCodeElimination) {
|
||||
// When dead-code elimination is enabled, all code should be reachable and an
|
||||
// associated block should already exist.
|
||||
SkASSERT(fCurrentBlock);
|
||||
} else {
|
||||
// When dead-code elimination is disabled, we may find ourselves with instructions
|
||||
// that don't have an associated block. This should be a rare event, but if it
|
||||
// happens, synthesize a label; this is necessary to satisfy the validator.
|
||||
if (fCurrentBlock == 0) {
|
||||
this->writeLabel(this->nextId(), out);
|
||||
}
|
||||
} else {
|
||||
// When dead-code elimination is enabled, all code should be reachable and an
|
||||
// associated block should already exist.
|
||||
SkASSERT(fCurrentBlock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
this->writeWord((length << 16) | opCode, out);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user