[PATCH] D131471: [RISCV] Fold (sub constant, (setcc x, y, eq/neq)) -> (add constant - 1, (setcc x, y, neq/eq))

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 10 08:44:35 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:8275
+  // (add constant - 1, (setcc x, y, neq/eq))
+  if (isa<ConstantSDNode>(N0) && N1.getOpcode() == ISD::SETCC) {
+    auto *Nnz0 = cast<ConstantSDNode>(N0);
----------------
liaolucy wrote:
> craig.topper wrote:
> > Do we need to check that this is the only user of the setcc?
> At present, I think only setcc, ensure that rd is only 0/1, I have not found other SDNode have this function.
That wasn’t my question. What if the setcc is used by another instruction other than this sub. Then the original  setcc won’t be removed and there will be two setccs with opposite conditions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131471



More information about the llvm-commits mailing list