[PATCH] D127275: [MVE] Fold fadd(select(..., +0.0)) into a predicated fadd

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 05:59:53 PDT 2022


dmgreen added a comment.

Oh, sorry - I did misread your comment. I should have said No, that's not how floating point fadd works :)
`fadd -0.0, 0.0` is `0.0`. The identity value for a fadd is `-0.0`. A `vaddt.f32 Qd, Qn, Qm` with a false lane predicate will take the original value of Qd unchanged for that lane (so if Qd==Qn, the original value from the input will be used, without any addition).

Luckily though, the transform you are altering is in terms of VSELECT and FADD nodes, which have the standard definitions, and you can think about without considering MVE specifics. The transform just needs to be valid in general.

  Old: fadd (select c, y, 0), x
  true -> fadd y, x
  false -> fadd 0, x
  
  New: select c, (fadd x, y), x
  true -> fadd x, y
  false -> x

Which is only valid if `fadd 0, x` is `x`, which needs nsz.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127275/new/

https://reviews.llvm.org/D127275



More information about the llvm-commits mailing list