[PATCH] D122563: [RISCV] Add DAGCombine to fold base operation and reduction.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 00:11:04 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:7265
+  // Make sure the scalar vector of Reduce is splat of neutral element.
+  if (ScalarV.getOpcode() != RISCVISD::VFMV_S_F_VL &&
+      ScalarV.getOpcode() != RISCVISD::VMV_S_X_VL &&
----------------
I missed it before, but I believe you need to be able to prove that the VL parameter for the splat isn't 0. In the usual case it's a constant 1 right? S o you can probably just check that it's a constant that isn't 0.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:7273
+    if (Opc == ISD::FADD && N->getFlags().hasNoSignedZeros())
+      return isNullFPConstant(V);
+    return DAG.getNeutralElement(Opc, SDLoc(V), V.getSimpleValueType(),
----------------
I think you want the isNullFPConstant in the `if` and a `return true` here. Just because hasNoSignedZeros is true doesn't mean that -0.0 can't appear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122563



More information about the llvm-commits mailing list