[PATCH] D94035: [RISCV] Don't parse 'vsltu.vi v0, v1, 0' as 'vsleu.vi v0, v1, -1'

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 4 15:09:41 PST 2021


craig.topper created this revision.
craig.topper added reviewers: HsiangKai, lenary, evandro, frasercrmck.
Herald added subscribers: NickHung, luismarques, apazos, sameer.abuasal, pzheng, 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.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.

vsltu.vi v0, v1, 0 is always false there is no unsigned number
less than 0. vsleu.vi v0, v1, -1 on the other hand is always true
since -1 will be considered unsigned max and all numbers are <=
unsigned max.

A similar problem exists for vsgeu.vi v0, v1, 0 which is always true,
but becomes vslgtu.vi v0, v1, -1 which is always false.

To match the GNU assembler we'll emit vmsne.vv and vmseq.vv with
the same register for these cases instead.

I'm using AsmParserOnly pseudo instructions here because we can't
match an explicit immediate in an InstAlias. And we can't use a
AsmOperand for the zero because the output we want doesn't use an
immediate so there's nowhere to name the AsmOperand we want to use.

To keep the implementations similar I'm also handling signed with
pseudo instructions even though they don't have this issue. This
way we can avoid the special renderMethod that decremented by 1 so
the immediate we see for the pseudo instruction in processInstruction
is 0 and not -1. Another option might have been to have a different
simm5_plus1 operand for the unsigned case or just live with the
immediate being pre-decremented. I felt this way was clear, but I'm
open to other opinions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94035

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/test/MC/RISCV/rvv/compare.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94035.314458.patch
Type: text/x-patch
Size: 7356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210104/39625570/attachment.bin>


More information about the llvm-commits mailing list