[PATCH] D101485: [RISCV] Teach DAG combine to fold (and (select_cc lhs, rhs, cc, -1, c), x) -> (select_cc lhs, rhs, cc, x, (and, x, c))

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 07:53:57 PDT 2021


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:5192-5193
+
+  if (Slct.getOpcode() != RISCVISD::SELECT_CC || !Slct.hasOneUse())
+    return SDValue();
+
----------------
luismarques wrote:
> Putting this here is a clean and safe way to write it, but I wonder if this should be moved to `combineSelectCCAndUseCommutative` to avoid repeated work, or if that would be confusing and error-prone for future changes?
It shouldn't be repeated work. The Slct and OtherOp operands are swapped for the second call from `combineSelectCCAndUseCommutative`


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

https://reviews.llvm.org/D101485



More information about the llvm-commits mailing list