https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106691
Bug ID: 106691 Summary: Section anchors is not implemented for riscv Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: riscv Take: static int a, b; int f(void) { return a+b; } void g(int c, int d) { a = c; b = d; } --- CUT --- Right now riscv32-linux-gnu produces: f: lui a5,%hi(a) lw a0,%lo(a)(a5) lui a5,%hi(b) lw a5,%lo(b)(a5) add a0,a0,a5 ret g: lui a5,%hi(a) sw a0,%lo(a)(a5) lui a5,%hi(b) sw a1,%lo(b)(a5) ret While aarch64 produces: f: adrp x0, .LANCHOR0 add x2, x0, :lo12:.LANCHOR0 ldr w1, [x0, #:lo12:.LANCHOR0] ldr w0, [x2, 4] add w0, w1, w0 ret g: adrp x2, .LANCHOR0 add x3, x2, :lo12:.LANCHOR0 str w0, [x2, #:lo12:.LANCHOR0] str w1, [x3, 4] ret One less instruction.