[PATCH] D130659: [RISCV] Update lowerFROUND to use masked instructions.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 08:21:25 PDT 2022


reames accepted this revision.
reames added a comment.

LGTM to me too.

Side note - this seems reasonably likely to be profitable for this specific case since all of the instructions are very likely to be scheduled together, but have you thought about the general applicability of a transform like this?  Having the mask register class be so constrained could make this unprofitable if the instructions were intermixed with other computation using a different mask.

The "general transform" I'm noting here is that we have select mask, f(x), x -> f(x, mask).  This is principle applies to any code sequence, and is not at all specific to floating point.



================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1919
+      DAG.getConstantFP(MaxVal, DL, ContainerVT.getVectorElementType());
+  SDValue MaxValSplat = DAG.getNode(RISCVISD::VFMV_V_F_VL, DL, ContainerVT,
+                                    DAG.getUNDEF(ContainerVT), MaxValNode, VL);
----------------
Why is the explicit splat here needed?  getConstantFP seems to do generate a splat internally, and the old code relied on that behavior.  Why change it to create the scalar constant (explicitly) and then splat (explicitly)?


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1933
+      DAG.getConstantFP(Point5Pred, DL, ContainerVT.getVectorElementType());
+  SDValue Splat = DAG.getNode(RISCVISD::VFMV_V_F_VL, DL, ContainerVT,
+                              DAG.getUNDEF(ContainerVT), SplatVal, VL);
----------------
Same question as above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130659



More information about the llvm-commits mailing list