From cd791bd0925e4be8b32636b44dfa44b24a5bbc1a Mon Sep 17 00:00:00 2001 From: Jhanani Thiagarajan Date: Wed, 13 Sep 2023 17:08:12 +0000 Subject: [PATCH] Adding an extra case for Fast Math Constant Handling Adding an extra case for Fast Math Constant Handling --- .../FastMathConstantHandling.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/IGC/AdaptorCommon/FastMathConstantHandling.cpp b/IGC/AdaptorCommon/FastMathConstantHandling.cpp index 485b8844dec5..ae7ac9a1669d 100644 --- a/IGC/AdaptorCommon/FastMathConstantHandling.cpp +++ b/IGC/AdaptorCommon/FastMathConstantHandling.cpp @@ -27,6 +27,9 @@ class FastMathConstantHandling : public FunctionPass, public InstVisitor= 10 + void visitFNeg(Instruction& I); +#endif virtual llvm::StringRef getPassName() const override { return "Fast Math Constant Handling"; } void getAnalysisUsage(AnalysisUsage& AU) const override @@ -61,7 +64,7 @@ void FastMathConstantHandling::visitInstruction(Instruction& I) bool hasInf = false; bool hasNan = false; bool hasNegZero = false; - } BSC; + }BSC; for (auto &Op : I.operands()) { @@ -84,6 +87,20 @@ void FastMathConstantHandling::visitInstruction(Instruction& I) I.setHasNoSignedZeros(false); } } +#if LLVM_VERSION_MAJOR >= 10 +void FastMathConstantHandling::visitFNeg(Instruction& I) +{ + auto* fp_val = dyn_cast(I.getOperand(0)); + if (fp_val && fp_val->getValueAPF().isZero()) + { + for (auto* UI : I.users()) + { + if (isa(UI)) + cast(UI)->setHasNoSignedZeros(false); + } + } +} +#endif bool FastMathConstantHandling::runOnFunction(Function& F) {