https://sourceware.org/bugzilla/show_bug.cgi?id=31175
Bug ID: 31175 Summary: RISCV load immediate relaxation leaves redundant addi Product: binutils Version: 2.39 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: iwfinlay at gmail dot com Target Milestone: --- Created attachment 15261 --> https://sourceware.org/bugzilla/attachment.cgi?id=15261&action=edit Tar of --save-temps and source to build image Per the GCC g++ feedback (originally filed there), linker relaxation should remove the addi/mv in the cases 1, 2, 3. The following is an excerpt from objdump of the ELF. 20010064 <_Z6globalv>: 20010064: 80000537 lui a0,0x80000 20010068: 00050513 mv a0,a0 <-- (1) 2001006c: 00008067 ret 20010070 <_Z4initv>: 20010070: 800007b7 lui a5,0x80000 20010074: 00078793 mv a5,a5 <-- (2) 20010078: 3e700713 li a4,999 2001007c: 00e7a223 sw a4,4(a5) # 80000004 <__global_pointer$+0xfffff804> 20010080: 0ea00713 li a4,234 20010084: 00e7a423 sw a4,8(a5) 20010088: 00008067 ret 2001008c <_Z5pcnt0v>: 2001008c: 800007b7 lui a5,0x80000 20010090: 00078793 mv a5,a5 <-- (3) 20010094: 0047a703 lw a4,4(a5) # 80000004 <__global_pointer$+0xfffff804> 20010098: 60271713 cpop a4,a4 Command line: riscv64-unknown-elf-g++ --save-temps -march=rv32imv_zbb_zbs -mabi=ilp32 -O3 -Wall -Wextra -o relax.elf main.cpp test.cpp startup.cpp -fno-builtin -static -fno-common -mcmodel=medlow -nostdlib -T link.ld riscv64-unknown-elf-objdump -d relax.elf > relax.disasm -- You are receiving this mail because: You are on the CC list for the bug.