[PATCH] D155908: [RISCV] Use original mask for restoring the original sign instead of from setcc

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 21:48:26 PDT 2023


craig.topper added a comment.

In D155908#4521197 <https://reviews.llvm.org/D155908#4521197>, @fakepaper56 wrote:

> In D155908#4521179 <https://reviews.llvm.org/D155908#4521179>, @Jim wrote:
>
>> During lowering rounding operation, it is converted to the absolute value with the mask that is from vp (or all ones mask for unmasked),
>> and compare with the largest integer that can be represented exactly. This comparision generates new mask that is used to only convert
>> the value less than the largest integer. The end, we copy the sign back to the value that should use the old mask the same with fabs operation.
>
> I think those elements inactive for `SetccMask` are not changed during the truncation and we don't care them.

I don't think there was a bug here either. The passthru value for the copysign is the original source before the absolute value.



================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:2623
   // Restore the original sign so that -0.0 is preserved.
   Truncated = DAG.getNode(RISCVISD::FCOPYSIGN_VL, DL, ContainerVT, Truncated,
                           Src, Src, Mask, VL);
----------------
All of the operations that produced `Truncated` before this are using masked agnostic policy. `Mask` here is now a superset of `SetccMask`. So far all the bits in Mask that aren't set in SetccMask, we are copying the sign from elements in `Src` to "agnostic" elements in `Truncated`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155908



More information about the llvm-commits mailing list