This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize addition with immediate
ClosedPublic

Authored by benshi001 on Apr 24 2021, 9:09 PM.

Diff Detail

Event Timeline

benshi001 created this revision.Apr 24 2021, 9:09 PM
benshi001 requested review of this revision.Apr 24 2021, 9:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2021, 9:10 PM
jrtc27 added inline comments.Apr 24 2021, 9:12 PM
llvm/lib/Target/RISCV/RISCVInstrInfo.td
1303

Misleading name given the hasOneUse

benshi001 marked an inline comment as done.
craig.topper added inline comments.Apr 24 2021, 11:04 PM
llvm/lib/Target/RISCV/RISCVInstrInfo.td
1303

I think the more common way to do this is to have to have an "add_oneuse" PatFrag that call N->hasOneUse()

See and_su, xor_su, fmul_su in ARMInstrInfo.td or and_su, srl_su, trunc_su in X86/X86InstrInfo.td. _su in all of those stands for "single use", but "_oneuse" is more readable

benshi001 marked an inline comment as done.
craig.topper added inline comments.Apr 25 2021, 6:59 PM
llvm/lib/Target/RISCV/RISCVInstrInfo.td
348

I'm confused why this works. The types on RV64 are all i64. I don't think tablegen should be accepting an i32. Does the pattern work if you use AddiPair?

benshi001 updated this revision to Diff 340422.Apr 25 2021, 8:18 PM
benshi001 marked an inline comment as done.
benshi001 added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfo.td
348

Yes. It works with only AddiPair, and I have removed the Addi32Pair.

benshi001 marked an inline comment as done.Apr 25 2021, 8:20 PM
This revision is now accepted and ready to land.Apr 25 2021, 9:46 PM
This revision was automatically updated to reflect the committed changes.