[3/3] LoongArch: Micro-optimize LD_PCREL

Message ID 20230826163651.35828-4-xry111@xry111.site
State Committed
Commit 3efa26749e4d28768558330353dc15c6f325ed4e
Headers
Series LoongArch: Clean up after Binutils minimal version bump |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed

Commit Message

Xi Ruoyao Aug. 26, 2023, 4:36 p.m. UTC
  We are requiring Binutils >= 2.41, so explicit relocation syntax is
always supported by the assembler.  Use it to reduce one instruction.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
 sysdeps/unix/sysv/linux/loongarch/pointer_guard.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
  

Patch

diff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
index b25e353b37..d6c78687d4 100644
--- a/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
+++ b/sysdeps/unix/sysv/linux/loongarch/pointer_guard.h
@@ -19,17 +19,15 @@ 
 #ifndef POINTER_GUARD_H
 #define POINTER_GUARD_H
 
-/* Load a got-relative EXPR into G, using T.
-   Note G and T are register names.  */
+/* Load a got-relative EXPR into register G.  */
 #define LD_GLOBAL(G, EXPR) \
   la.global G,  EXPR; \
   REG_L     G,  G,  0;
 
-/* Load a pc-relative EXPR into G, using T.
-   Note G and T are register names.  */
+/* Load a pc-relative EXPR into register G.  */
 #define LD_PCREL(G, EXPR) \
-  la.pcrel  G,  EXPR; \
-  REG_L     G,  G,  0;
+  pcalau12i G, %pc_hi20(EXPR); \
+  REG_L     G, G, %pc_lo12(EXPR);
 
 #if (IS_IN (rtld) \
      || (!defined SHARED && (IS_IN (libc) \