@@ -1573,6 +1573,32 @@ bool SpirvEmitter::handleNodePayloadArrayType(const ParmVarDecl *decl,
15731573 }
15741574}
15751575
1576+ // -O1experimental is intended to bundle three effects:
1577+ // 1. the fast optimizer recipe,
1578+ // 2. the targeted loop-unroll behavior,
1579+ // 3. the narrower SSA / composite-resource cleanup needed after (1) and (2)
1580+ // change the IR shape.
1581+ //
1582+ // (1) and (2) are the main value of the profile and are generally desirable for
1583+ // every shader compiled with -O1experimental. The trouble is that some HLSL
1584+ // type graphs still require more precise handling in the current "special
1585+ // types" cleanup than SPIRV-Tools provides today. In particular, nested
1586+ // AliasedPointer / BDA wrappers and opaque composite resources can reach the
1587+ // fast path and produce invalid SPIR-V if we let the current cleanup touch
1588+ // them blindly.
1589+ //
1590+ // This producer-side scan is therefore a safety valve: if a risky type appears
1591+ // anywhere in the type graph, we force the module back to the default SPIR-V
1592+ // path instead of letting the experimental fast profile emit invalid code.
1593+ // We are taking this route as a tactical stopgap because there was not enough
1594+ // time to finish a sound, more selective SPIRV-Tools-side implementation of
1595+ // the "special types" cleanup before wiring the profile through the PR stack.
1596+ //
1597+ // The preferred long-term shape is narrower than this guard: keep the fast
1598+ // recipe and loop-unroll behavior for every -O1experimental module, and make
1599+ // the "special types" cleanup in SPIRV-Tools selective enough that only the
1600+ // truly risky part of (3) is disabled. Until that path is sound, this
1601+ // conservative fallback keeps the profile correct.
15761602void SpirvEmitter::noteExperimentalFastCompileRisk(
15771603 QualType type, bool hasAliasedPointerAttr) {
15781604 if (!spirvOptions.o1ExperimentalFastCompile || type.isNull())
@@ -16757,6 +16783,12 @@ bool SpirvEmitter::spirvToolsOptimize(std::vector<uint32_t> *mod,
1675716783}
1675816784
1675916785bool SpirvEmitter::useSpirvFastCompileProfile() const {
16786+ // This currently gates the whole experimental profile, not just the narrow
16787+ // "special types" cleanup. That is intentionally conservative for now:
16788+ // correctness wins over preserving the fast recipe on unsupported type
16789+ // shapes. Once SPIRV-Tools can scope the risky part of the cleanup more
16790+ // precisely, -O1experimental should keep the fast recipe / unroll path and
16791+ // only disable the problematic subset of the rewrite logic.
1676016792 return spirvOptions.o1ExperimentalFastCompile &&
1676116793 spirvOptions.optConfig.empty() &&
1676216794 !experimentalFastCompileRequiresDefaultPath &&
0 commit comments