[PATCH] D151719: [RISCV] Add special case for (select cc, 1.0, 0.0) to lowerSELECT

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 30 20:45:58 PDT 2023


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:5501
+  const ConstantFPSDNode *FPFV = dyn_cast<ConstantFPSDNode>(FalseV);
+  if (FPTV && FPFV && FPTV->isExactlyValue(1.0) && FPFV->isExactlyValue(0.0)) {
+    return DAG.getNode(ISD::SINT_TO_FP, DL, VT, CondV);
----------------
Drop curly braces


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:5573
+  // (select_cc 0, x, setlt, 0.0, 1.0)
+  // -> (sint_to_fp (zext (setcc x, 1, setlt)))
+  if (FPTV && FPFV && isNullConstant(LHS) && CCVal == ISD::CondCode::SETLT &&
----------------
Why not handle this like the earlier, but use an XOR with 1 to flip the condition? Wouldn't that always better than the branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151719



More information about the llvm-commits mailing list