[llvm] [InstCombine] Enable FAdd simplifications when user can ignore sign bit (PR #157757)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 11 00:14:07 PDT 2025
================
@@ -2002,6 +2002,16 @@ Instruction *InstCombinerImpl::visitFAdd(BinaryOperator &I) {
if (Instruction *FoldedFAdd = foldBinOpIntoSelectOrPhi(I))
return FoldedFAdd;
+ // B = fadd A, 0
+ // Z = Op B
+ // can be transformed into
+ // Z = Op A
+ // Where Op is such that we can ignore sign of 0 in fadd
+ Value *A;
+ if (match(&I, m_c_FAdd(m_Value(A), m_AnyZeroFP())) && !I.use_empty() &&
----------------
nikic wrote:
This needs to check for one use, otherwise you're only checking that the transform is safe for a single use, but doing it for all of them. Please also add multi use test.
https://github.com/llvm/llvm-project/pull/157757
More information about the llvm-commits
mailing list