Skip to content

Commit 1b89420

Browse files
srividyakarumurigfxbot
authored andcommitted
Before doing fdiv optimization to convert to inv+mul, checking
if the instruction allows reciprocal. Change-Id: I260cf0af65ea39c3c5f9a6c8923677af6fc11c72
1 parent 72c4df4 commit 1b89420

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

IGC/Compiler/CustomUnsafeOptPass.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,10 +1663,13 @@ void CustomUnsafeOptPass::visitBinaryOperator(BinaryOperator &I)
16631663
{
16641664
if (!(fp0 && fp0->isExactlyValue(1.0)))
16651665
{
1666-
Value *invOp = copyIRFlags(BinaryOperator::CreateFDiv(ConstantFP::get(opType, 1.0), op1, "", &I), &I);
1667-
I.replaceAllUsesWith(
1668-
copyIRFlags(BinaryOperator::CreateFMul(op0, invOp, "", &I), &I));
1669-
patternFound = true;
1666+
if (m_ctx->getModuleMetaData()->compOpt.FastRelaxedMath || I.hasAllowReciprocal())
1667+
{
1668+
Value *invOp = copyIRFlags(BinaryOperator::CreateFDiv(ConstantFP::get(opType, 1.0), op1, "", &I), &I);
1669+
I.replaceAllUsesWith(
1670+
copyIRFlags(BinaryOperator::CreateFMul(op0, invOp, "", &I), &I));
1671+
patternFound = true;
1672+
}
16701673
}
16711674
}
16721675
}

0 commit comments

Comments
 (0)