diff --git a/sysdeps/loongarch/__longjmp.S b/sysdeps/loongarch/__longjmp.S
index 191f03320a..302cb6894a 100644
--- a/sysdeps/loongarch/__longjmp.S
+++ b/sysdeps/loongarch/__longjmp.S
@@ -23,9 +23,9 @@
 ENTRY (__longjmp)
 #ifdef PTR_MANGLE
 	REG_L t0, a0, 0*SZREG
-	PTR_DEMANGLE (ra, t0, t1)
+	PTR_DEMANGLE (ra, t0, t1, t2)
 	REG_L t0, a0, 1*SZREG
-	PTR_DEMANGLE2 (sp, t0, t1)
+	PTR_DEMANGLE2 (sp, t0, t1, t2)
 #else
 	REG_L ra, a0, 0*SZREG
 	REG_L sp, a0, 1*SZREG
diff --git a/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h b/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h
index 75498545cb..8fe7d1e15a 100644
--- a/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h
+++ b/sysdeps/unix/sysv/linux/loongarch/pointer_guard-asm.h
@@ -32,16 +32,16 @@
 # define PTR_MANGLE(dst, src, guard) \
   PTR_MANGLE_LOAD (guard); \
   PTR_MANGLE2 (dst, src, guard);
-# define PTR_DEMANGLE(dst, src, guard) \
+# define PTR_DEMANGLE(dst, src, guard, tmp) \
   PTR_MANGLE_LOAD (guard); \
-  PTR_DEMANGLE2 (dst, src, guard);
+  PTR_DEMANGLE2 (dst, src, guard, tmp);
 /* Use PTR_MANGLE2 for efficiency if guard is already loaded.  */
 # define PTR_MANGLE2(dst, src, guard) \
   xor  dst, src, guard; \
   rotri.d  dst, dst, 47;
-# define PTR_DEMANGLE2(dst, src, guard) \
-  rotri.d  dst, src, 17; \
-  xor  dst, dst, guard;
+# define PTR_DEMANGLE2(dst, src, guard, tmp) \
+  rotri.d  tmp, src, 17; \
+  xor  dst, tmp, guard;
 #endif
 
 #endif /* POINTER_GUARD_ASM_H */
