This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][test] Add new tests of or/xor in the zbs extension
AbandonedPublic

Authored by benshi001 on May 20 2021, 10:14 AM.

Diff Detail

Event Timeline

benshi001 created this revision.May 20 2021, 10:14 AM
benshi001 requested review of this revision.May 20 2021, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2021, 10:14 AM
jrtc27 added inline comments.May 20 2021, 10:39 AM
llvm/test/CodeGen/RISCV/rv32zbs.ll
805

Everything should always be optimised, but you mean a specific optimisation doesn't apply

craig.topper added inline comments.May 20 2021, 11:57 AM
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
122 ↗(On Diff #346777)

What if bit 11 is the most significant set bit. We can use BSETI/BINVI for it and leave bits 10:0 for the ORI/XORI

130 ↗(On Diff #346777)

I think it's ok to use isPowerOf2_64 even for RV32. I was zero extended so the upper bits are 0.

benshi001 updated this revision to Diff 346891.May 20 2021, 4:53 PM
benshi001 retitled this revision from [RISCV] Optimize or/xor with immediate in the zbs extension to [RISCV][test] Add new tests of or/xor in the zbs extension.
benshi001 edited the summary of this revision. (Show Details)
benshi001 marked an inline comment as done.
benshi001 added inline comments.
llvm/test/CodeGen/RISCV/rv32zbs.ll
805

This patch will show how

lui r1, xxx
addi r1, r1, yyy
or r0, r0, r1

will be optimized to

ori r0, r0, zzz
bseti r0, 11
bseti r0, hi

An extra register is saved.

Did you mean to replace the previous patch with new tests?

llvm/test/CodeGen/RISCV/rv32zbs.ll
805

I think @jrtc27 means the comment should be understandable by someone in the future without needing to know about a specific patch/commit.

jrtc27 added inline comments.May 20 2021, 5:18 PM
llvm/test/CodeGen/RISCV/rv32zbs.ll
805

Yes, the comment is complete nonsense when you read the file, it only makes some amount of sense when looking specifically at this diff, but even then is not the best way to express that.

benshi001 marked an inline comment as done.May 20 2021, 5:47 PM

Did you mean to replace the previous patch with new tests?

Sorry. I mean to replace the previous patch with new tests. And I will submit the optimization patch later.

llvm/test/CodeGen/RISCV/rv32zbs.ll
805

I see. I will pay attention my way in the future.