-
- Downloads
LoongArch: Use explicit relocs for addresses only used for one load or store...
LoongArch: Use explicit relocs for addresses only used for one load or store with -mexplicit-relocs=auto and -mcmodel={normal,medium} In these cases, if we use explicit relocs, we end up with 2 instructions: pcalau12i t0, %pc_hi20(x) ld.d t0, t0, %pc_lo12(x) If we use la.local pseudo-op, in the best scenario (x is in +/- 2MiB range) we still have 2 instructions: pcaddi t0, %pcrel_20(x) ld.d t0, t0, 0 If x is out of the range we'll have 3 instructions. So for these cases just emit machine instructions with explicit relocs. gcc/ChangeLog: * config/loongarch/predicates.md (symbolic_pcrel_operand): New predicate. * config/loongarch/loongarch.md (define_peephole2): Optimize la.local + ld/st to pcalau12i + ld/st if the address is only used once if -mexplicit-relocs=auto and -mcmodel=normal or medium. gcc/testsuite/ChangeLog: * gcc.target/loongarch/explicit-relocs-auto-single-load-store.c: New test. * gcc.target/loongarch/explicit-relocs-auto-single-load-store-no-anchor.c: New test.
Showing
- gcc/config/loongarch/loongarch.md 122 additions, 0 deletionsgcc/config/loongarch/loongarch.md
- gcc/config/loongarch/predicates.md 7 additions, 0 deletionsgcc/config/loongarch/predicates.md
- gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-single-load-store-no-anchor.c 6 additions, 0 deletions...ngarch/explicit-relocs-auto-single-load-store-no-anchor.c
- gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-single-load-store.c 14 additions, 0 deletions...target/loongarch/explicit-relocs-auto-single-load-store.c
Loading
Please register or sign in to comment