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>
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 0768254..3bd700e 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -236,18 +236,21 @@
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);
}