starfive-tech / opensbi

Other
17 stars 16 forks source link

Minor optimization to sbi_strlen #3

Closed robertlipe closed 3 years ago

robertlipe commented 3 years ago

Minor optimization to sbi_strlen

There are algorthimically more clever ways to do strlen(), but the original implementation has a hot loop of 4 opcodes instead of 3. This changes the per-character body from:

.L3:
addi a5,a5,1
add a4,a0,a5
lbu a4,0(a4)
bne a4,zero,.L3

to

.L3:
lbu a4,1(a5)
addi a5,a5,1
bne a4,zero,.L3

While keeping the source CS101 level of complexity.

strnlen() could probably benefit from a similar change...

Originally from: https://github.com/starfive-tech/sft-riscv-opensbi/pull/2/files ...and https://github.com/starfive-tech/opensbi/pull/2

pdp7 commented 3 years ago

@robertlipe thanks for raising this PR now that we have reorganized the branches

@tekkamanninja @avpatel @lbmeng could you please take a look?

pdp7 commented 3 years ago

@avpatel should this sent to the mailing list instead?

avpatel commented 3 years ago

Overall, patch looks good so please go ahead and send it to mailing list

Regards, Anup

pdp7 commented 3 years ago

Please submit to the opensbi mailing as @avpatel sugested as this should go to opensbi upstream

robertlipe commented 3 years ago

This is already my third generation. I'm over it.

On Wed, Jul 7, 2021, 2:21 PM Drew Fustini @.***> wrote:

Closed #3 https://github.com/starfive-tech/opensbi/pull/3.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/starfive-tech/opensbi/pull/3#event-4990756230, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCSD32VDNNM2OTFV323ZQTTWSLJRANCNFSM45SRKR4A .