[PATCH] D158907: [RISCV][GlobalISel] Select G_ICMP, G_IMPLICIT_DEF

Nitin John Raj via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 10:47:54 PDT 2023


nitinjohnraj created this revision.
nitinjohnraj added reviewers: craig.topper, arsenm.
Herald added subscribers: jobnoorman, luke, sunshaoce, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
nitinjohnraj updated this revision to Diff 553990.
nitinjohnraj added a comment.
nitinjohnraj published this revision for review.
Herald added subscribers: llvm-commits, wangpc, eopXD, MaskRay, wdng.
Herald added a project: LLVM.

Handling the `G_ICMP ugt %x -1` case



================
Comment at: llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp:231
+
+    if (!buildLTImm(TmpReg, SrcReg1, Imm + 1, IsSigned))
+      return false;
----------------
There's a corner case here for Predicate::ICMP_UGT with Imm=-1. That compare should return false because nothing is larger than -1, but if you increment it and turn it into ICMP_ULT with imm 0 followed by XOR, it would always produce true.


RISCV ISA only has instructions for checking if a number is less than another. We select for all conditional codes in terms of these.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158907

Files:
  llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
  llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp32.mir
  llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/cmp64.mir
  llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/implicit-def32.mir
  llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/implicit-def64.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158907.553990.patch
Type: text/x-patch
Size: 41699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230828/b7e4cc3b/attachment.bin>


More information about the llvm-commits mailing list