Skip to content

Commit 74aa563

Browse files
PawelJurekigcbot
authored andcommitted
Respect per instruction contraction flag in mad pattern match.
SPV_INTEL_fp_fast_math_mode introduces AllowContractFastINTEL fast math flag. When instruction is decorated with this flag, contractions are allowed even if it may violate language standard. This enum maps to LLVM fast math flags, but was not respected in "mad" instruction pattern match.
1 parent 91f3e3a commit 74aa563

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,9 +2025,18 @@ namespace IGC
20252025
{
20262026
return false;
20272027
}
2028+
2029+
bool isFpMadWithContractionOverride = false;
20282030
if (isFpMad(I) && m_AllowContractions == false)
20292031
{
2030-
return false;
2032+
if (I.hasAllowContract())
2033+
{
2034+
isFpMadWithContractionOverride = true;
2035+
}
2036+
else
2037+
{
2038+
return false;
2039+
}
20312040
}
20322041
if (!isFpMad(I) && !(m_Platform.doIntegerMad() && m_ctx->m_DriverInfo.EnableIntegerMad()))
20332042
{
@@ -2067,6 +2076,10 @@ namespace IGC
20672076
// in case we know we won't be able to remove the mul we don't merge it
20682077
if (!m_PosDep->PositionDependsOnInst(mul) && NeedInstruction(*mul))
20692078
continue;
2079+
2080+
if (isFpMadWithContractionOverride && !mul->hasAllowContract())
2081+
continue;
2082+
20702083
sources[2] = I.getOperand(1 - i);
20712084
sources[1] = mul->getOperand(0);
20722085
sources[0] = mul->getOperand(1);

0 commit comments

Comments
 (0)