This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][GlobalISel] Select G_ICMP, G_IMPLICIT_DEF
Changes PlannedPublic

Authored by nitinjohnraj on Aug 25 2023, 4:12 PM.

Details

Summary

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

Diff Detail

Event Timeline

nitinjohnraj created this revision.Aug 25 2023, 4:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2023, 4:12 PM
craig.topper added inline comments.Aug 25 2023, 11:09 PM
llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
231

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.

nitinjohnraj updated this revision to Diff 553990.EditedAug 28 2023, 10:37 AM

Handling the G_ICMP intpred(ugt), %x, -1 case

nitinjohnraj published this revision for review.Aug 28 2023, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2023, 10:47 AM
nitinjohnraj planned changes to this revision.Aug 28 2023, 10:50 AM

I changed the way I was handling HasImm to match SelectionDAG, but on closer look I think I might be making a mistake? Let me quickly look into this.

HasImm = IsInt<12>(V)

nitinjohnraj planned changes to this revision.Aug 28 2023, 5:09 PM

We should try adding the rules to the tablegen.

llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
222

Make this 0

235

Nest if statements