[all-commits] [llvm/llvm-project] 924907: [DAG] Prefer 0.0 over -0.0 as neutral value for FA...

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Aug 30 07:56:35 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 924907bc6aa17bb15241143dc9858da971b25908
      https://github.com/llvm/llvm-project/commit/924907bc6aa17bb15241143dc9858da971b25908
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2024-08-30 (Fri, 30 Aug 2024)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-fp.ll

  Log Message:
  -----------
  [DAG] Prefer 0.0 over -0.0 as neutral value for FADD w/NoSignedZero (#106616)

When getting a neutral value, we can prefer using a positive zero over a
negative zero if nsz is set on the FADD (or reduction). A positive zero
should be cheaper to materialize on basically all targets.

Arguably, we should be doing this kind of canonicalization in
DAGCombine, but we don't do that for any of the other reduction
variants, so this seems like path of least resistance. This does mean
that we can only do this for "fast" reductions. Just nsz isn't enough,
as that goes through the SEQ_FADD path where the IR level start value
isn't folded away.

If folks think this is to RISCV specific, let me know. There's a trivial
RISCV specific implementation. I went with the generic one as I through
this might benefit other targets.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list