[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))

Luís Marques via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 08:56:18 PDT 2021


luismarques added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:5192-5193
+
+  if (Slct.getOpcode() != RISCVISD::SELECT_CC || !Slct.hasOneUse())
+    return SDValue();
+
----------------
craig.topper wrote:
> 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`
Yup, nevermind, I had a wrong mental model when I wrote that comment.


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

https://reviews.llvm.org/D101485



More information about the llvm-commits mailing list