diff --git a/src/compiler/translator/tree_util/IntermNodePatternMatcher.cpp b/src/compiler/translator/tree_util/IntermNodePatternMatcher.cpp index be55891eb5..70b740f8c9 100644 --- a/src/compiler/translator/tree_util/IntermNodePatternMatcher.cpp +++ b/src/compiler/translator/tree_util/IntermNodePatternMatcher.cpp @@ -51,8 +51,12 @@ bool IntermNodePatternMatcher::matchInternal(TIntermBinary *node, TIntermNode *p if ((mMask & kUnfoldedShortCircuitExpression) != 0) { - if (node->getRight()->hasSideEffects() && - (node->getOp() == EOpLogicalOr || node->getOp() == EOpLogicalAnd)) + // Bandaid for the HLSL port of angleproject:465831139: hasSideEffects() is + // not a sufficient gate here. An RHS like data[idx] has no side effects but + // is unsafe to execute speculatively (idx may be OOB), and HLSL &&/|| do NOT + // short-circuit. Unconditionally unfold all &&/|| (this already matches the + // behaviour for ternaries below, which are unconditionally unfolded). + if (node->getOp() == EOpLogicalOr || node->getOp() == EOpLogicalAnd) { return true; }