Skip to content

Commit cd791bd

Browse files
jhananitigcbot
authored andcommitted
Adding an extra case for Fast Math Constant Handling
Adding an extra case for Fast Math Constant Handling
1 parent 950349f commit cd791bd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

IGC/AdaptorCommon/FastMathConstantHandling.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class FastMathConstantHandling : public FunctionPass, public InstVisitor<FastMat
2727
static char ID;
2828
bool runOnFunction(Function& F) override;
2929
void visitInstruction(Instruction& I);
30+
#if LLVM_VERSION_MAJOR >= 10
31+
void visitFNeg(Instruction& I);
32+
#endif
3033
virtual llvm::StringRef getPassName() const override { return "Fast Math Constant Handling"; }
3134

3235
void getAnalysisUsage(AnalysisUsage& AU) const override
@@ -61,7 +64,7 @@ void FastMathConstantHandling::visitInstruction(Instruction& I)
6164
bool hasInf = false;
6265
bool hasNan = false;
6366
bool hasNegZero = false;
64-
} BSC;
67+
}BSC;
6568

6669
for (auto &Op : I.operands())
6770
{
@@ -84,6 +87,20 @@ void FastMathConstantHandling::visitInstruction(Instruction& I)
8487
I.setHasNoSignedZeros(false);
8588
}
8689
}
90+
#if LLVM_VERSION_MAJOR >= 10
91+
void FastMathConstantHandling::visitFNeg(Instruction& I)
92+
{
93+
auto* fp_val = dyn_cast<llvm::ConstantFP>(I.getOperand(0));
94+
if (fp_val && fp_val->getValueAPF().isZero())
95+
{
96+
for (auto* UI : I.users())
97+
{
98+
if (isa<FPMathOperator>(UI))
99+
cast<Instruction>(UI)->setHasNoSignedZeros(false);
100+
}
101+
}
102+
}
103+
#endif
87104

88105
bool FastMathConstantHandling::runOnFunction(Function& F)
89106
{

0 commit comments

Comments
 (0)