[llvm] [InstCombine] Support reassoc for foldLogicOfFCmps (PR #116065)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 22 10:22:26 PST 2024
================
@@ -1465,11 +1465,16 @@ Value *InstCombinerImpl::foldLogicOfFCmps(FCmpInst *LHS, FCmpInst *RHS,
// FCmp canonicalization ensures that (fcmp ord/uno X, X) and
// (fcmp ord/uno X, C) will be transformed to (fcmp X, +0.0).
- if (match(LHS1, m_PosZeroFP()) && match(RHS1, m_PosZeroFP()))
+ if (match(LHS1, m_PosZeroFP()) && match(RHS1, m_PosZeroFP())) {
// Ignore the constants because they are obviously not NANs:
// (fcmp ord x, 0.0) & (fcmp ord y, 0.0) -> (fcmp ord x, y)
// (fcmp uno x, 0.0) | (fcmp uno y, 0.0) -> (fcmp uno x, y)
+ IRBuilder<>::FastMathFlagGuard FMFG(Builder);
+ FastMathFlags FMF = LHS->getFastMathFlags();
+ FMF &= RHS->getFastMathFlags();
+ Builder.setFastMathFlags(FMF);
----------------
arsenm wrote:
You can do the and inline now
```suggestion
Builder.setFastMathFlags(LHS->getFastMathFlags() & RHS->getFastMathFlags());
```
https://github.com/llvm/llvm-project/pull/116065
More information about the llvm-commits
mailing list