diff options
author | Philip Reames <preames@rivosinc.com> | 2024-09-03 09:16:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 09:16:37 -0700 |
commit | 2c7786e94a1058bd4f96794a1d4f70dcb86e5cc5 (patch) | |
tree | 4e944381b7fd679ef7755621317c2f46cba30fc4 /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | df4746d1d076016095059da4af2a3c3cc54657fe (diff) | |
download | llvm-2c7786e94a1058bd4f96794a1d4f70dcb86e5cc5.zip llvm-2c7786e94a1058bd4f96794a1d4f70dcb86e5cc5.tar.gz llvm-2c7786e94a1058bd4f96794a1d4f70dcb86e5cc5.tar.bz2 |
Prefer use of 0.0 over -0.0 for fadd reductions w/nsz (in IR) (#106770)
This is a follow up to 924907bc6, and is mostly motivated by consistency
but does include one additional optimization. In general, we prefer 0.0
over -0.0 as the identity value for an fadd. We use that value in
several places, but don't in others. So, let's be consistent and use the
same identity (when nsz allows) everywhere.
This creates a bunch of test churn, but due to 924907bc6, most of that
churn doesn't actually indicate a change in codegen. The exception is
that this change enables the use of 0.0 for nsz, but *not* reasoc, fadd
reductions. Or said differently, it allows the neutral value of an
ordered fadd reduction to be 0.0.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 8a8d8af..61f7b23 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1213,7 +1213,8 @@ Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder, Value *Src, auto getIdentity = [&]() { Intrinsic::ID ID = getReductionIntrinsicID(RdxKind); unsigned Opc = getArithmeticReductionInstruction(ID); - return ConstantExpr::getBinOpIdentity(Opc, SrcVecEltTy); + bool NSZ = Builder.getFastMathFlags().noSignedZeros(); + return ConstantExpr::getBinOpIdentity(Opc, SrcVecEltTy, false, NSZ); }; switch (RdxKind) { case RecurKind::Add: |