From 21e69c0740ac29342c4c0a2762bcc1460bffffa8 Mon Sep 17 00:00:00 2001 From: Paul Kippes Date: Tue, 19 Sep 2023 21:20:59 +0000 Subject: [PATCH] Remove noinf for fdiv by 0 in FastMath Handling Remove noinf for fdiv by 0 in FastMathConstantHandling pass --- IGC/AdaptorCommon/FastMathConstantHandling.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IGC/AdaptorCommon/FastMathConstantHandling.cpp b/IGC/AdaptorCommon/FastMathConstantHandling.cpp index ae7ac9a1669d..8aecdba732e2 100644 --- a/IGC/AdaptorCommon/FastMathConstantHandling.cpp +++ b/IGC/AdaptorCommon/FastMathConstantHandling.cpp @@ -30,6 +30,7 @@ class FastMathConstantHandling : public FunctionPass, public InstVisitor= 10 void visitFNeg(Instruction& I); #endif + void visitFDiv(Instruction& I); virtual llvm::StringRef getPassName() const override { return "Fast Math Constant Handling"; } void getAnalysisUsage(AnalysisUsage& AU) const override @@ -102,6 +103,15 @@ void FastMathConstantHandling::visitFNeg(Instruction& I) } #endif +void FastMathConstantHandling::visitFDiv(Instruction& I) +{ + if (auto* fp_val = dyn_cast(I.getOperand(1)); + fp_val && fp_val->getValueAPF().isZero()) + { + I.setHasNoInfs(false); + } +} + bool FastMathConstantHandling::runOnFunction(Function& F) { if (IGC_IS_FLAG_DISABLED(DisableFastMathConstantHandling))