This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize immediate materialisation with SLLI.UW
ClosedPublic

Authored by benshi001 on Oct 16 2021, 3:14 AM.

Details

Summary

Simplify "LUI+SLLI+ADDI+SLLI" and "LUI+ADDIW+SLLI+ADDI+SLLI" to

"LUI+ADDIW+SLLIUW" to reduce total instruction amount.

Diff Detail

Event Timeline

benshi001 created this revision.Oct 16 2021, 3:14 AM
benshi001 requested review of this revision.Oct 16 2021, 3:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 16 2021, 3:14 AM

Your description is not accurate. You’re not replacing LUI+ADDI+SLLI. You’re replacing LUI+SLLI+ADDI+SLLI.

Your description is not accurate. You’re not replacing LUI+ADDI+SLLI. You’re replacing LUI+SLLI+ADDI+SLLI.

I should add more tests, sometimes my patch can reduce two instructions, for example

long ass() {
        return 0xbbbbb111777;
}

The original instructions are

lui a0, 188
addiw a0, a0, -1093
slli  a0, a0, 12
addi  a0, a0, 273
slli  a0, a0, 12
addi  a0, a0, 1911
ret

which can be optimized by my patch to

lui a0, 768955
addiw a0, a0, 273
slli.uw a0, a0, 12
addi  a0, a0, 1911
ret

Your description is not accurate. You’re not replacing LUI+ADDI+SLLI. You’re replacing LUI+SLLI+ADDI+SLLI.

So how about change the description to "Use LUI+ADDI+SLLI.UW to reduce multiple SLLI+ADDI pairs" ?

benshi001 updated this revision to Diff 380241.Oct 17 2021, 5:40 AM
benshi001 edited the summary of this revision. (Show Details)
benshi001 updated this revision to Diff 380268.Oct 17 2021, 7:35 PM

ping ... This would be the last patch of immediate materialisation optimization with the B extension. Can it be merged?

This revision is now accepted and ready to land.Oct 26 2021, 7:22 PM