Re: [PATCH 2/3] newlib: riscv: Optimize memchr() and memrchr()
Eric Salem <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
On 5/7/25 8:19 PM, Kito Cheng wrote:
> Hi Eric:
>
> Here is a local GCC patch for zilsd code gen, could you try that?
> I believe this should just fix that on the compiler side...
> let me know if further issue you found or you don't know how to build gcc
> Plan to push this to upstream GCC later if there is no further issue :)
>
> https://github.com/kito-cheng/gcc/tree/kitoc/zilsd-codegen
I had a hell of a time getting the cross compiler built, but it's at
least partially working. The assembler doesn't recognize Zilsd or Zclsd.
I think it still might be the binutils version (I had to build that
beforehand for the compiler).
In any case, here's the results I get. Without Zilsd:
$ riscv32-unknown-elf-gcc -march=rv32ic -mabi=ilp32 -O3 -S test.c
$ cat test.s
(output truncated)
main:
addi sp,sp,-32
li a4,5
li a5,7
lui a0,%hi(.LC0)
addi a1,sp,8
mv a2,a4
mv a3,a5
addi a0,a0,%lo(.LC0)
sw ra,28(sp)
sw a4,8(sp)
sw a5,12(sp)
call printf
lw ra,28(sp)
li a0,0
addi sp,sp,32
jr ra
.size main, .-main
.ident "GCC: (GNU) 16.0.0 20250430 (experimental)"
.section .note.GNU-stack,"",@progbits
With Zilsd:
$ riscv32-unknown-elf-gcc -march=rv32ic_zclsd_zilsd -mabi=ilp32 -O3 -S test.c
$ cat test.s
(output truncated)
main:
addi sp,sp,-32
li a4,5
li a5,7
lui a0,%hi(.LC0)
addi a1,sp,8
mv a2,a4
mv a3,a5
addi a0,a0,%lo(.LC0)
sw ra,28(sp)
sd a4,8(sp)
call printf
lw ra,28(sp)
li a0,0
addi sp,sp,32
jr ra
.size main, .-main
.ident "GCC: (GNU) 16.0.0 20250430 (experimental)"
.section .note.GNU-stack,"",@progbits
So GCC is at least generating the correct assembly. If Clang hasn't been
updated since I last built it, maybe you could convince them to somehow
incorporate your changes?