[PATCH] D95169: [RISCV] Add more cmov isel patterns to handle seteq/ne with a small non-zero immediate.

Michael Munday via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 22 02:42:27 PST 2021


mundaym accepted this revision.
mundaym added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoB.td:725
           (CMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
+def : Pat<(select (XLenVT (setne GPR:$x, simm12_plus1:$y)), GPR:$rs1, GPR:$rs3),
+          (CMOV GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)), GPR:$rs3)>;
----------------
Out of curiosity do you think it would make sense at some point to have a pass that just removes `ADDI x, 0` (and `XOR x, 0` etc.) after instruction selection? Then we could presumably delete the two patterns above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95169



More information about the llvm-commits mailing list