[PATCH v4 5/5] RISC-V: add zbb support to string functions
Jeff Law
jlaw at ventanamicro.com
Wed Jan 11 07:22:07 PST 2023
On 1/11/23 07:27, Christoph Müllner wrote:
>>> +
>>> +.option push
>>> +.option arch,+zbb
>>> +
>>> + /*
>>> + * Returns
>>> + * a0 - comparison result, value like strcmp
>>> + *
>>> + * Parameters
>>> + * a0 - string1
>>> + * a1 - string2
>>> + *
>>> + * Clobbers
>>> + * t0, t1, t2, t3, t4, t5
>>> + */
>>> + mv src2, a1
>>> +
>>> + or align, src1, src2
>>> + li m1, -1
>>> + and align, align, SZREG-1
>>> + bnez align, 3f
>>> +
>>> + /* Main loop for aligned string. */
>>> + .p2align 3
>>
>> Why are the starts of the loops aligned to 8 byte boundaries?
>
> Loop alignment seems to be a valid optimization method for other architectures.
> I don't see anything specific in RISC-V that would make loop alignment
> irrelevant.
Right. It's pretty common to see small, but observable performance
improvements on many uarchs due to code alignments. There's typically
three knobs to tune in this space. First is function alignment, second
is loop alignment, then finally other jump target alignments.
Drew, happy to sync on this if you want -- I've got a low priority TODO
to come up with some sensible guidelines for our v1 chip. I'm not too
inclined to push hard on it yet as it'll be a lot easier to find the
sweet spot once real hardware is available.
jeff
More information about the linux-riscv
mailing list