Tested on hppa-unknown-linux-gnu.  Committed to trunk.

Dave
---

hppa: Fix canonicalize_funcptr_for_compare expander

This fixes the case where the canonicalize_funcptr_for_compare
expander is called with a SYMBOL_REF that isn't a function
pointer.  This can happen when one side of the comparison is
a function pointer and the other side is a data or text symbol.

2026-10-04  John David Anglin  <[email protected]>

gcc/ChangeLog:

        * config/pa/pa.md (canonicalize_funcptr_for_compare): Check for 
        SYMBOL_REF targets that are not function addresses early and emit 
        a direct move instruction to bypass redundant libcall wrappers.

diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index 4148d0dacf4..6b83bf43aad 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -10199,6 +10199,15 @@ add,l %2,%3,%3\;bv,n %%r0(%3)"
   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
   "
 {
+  /* If operand 1 is an address calculation of a variable, do not emit
+     a redundant libcall wrapper.  Copy the address directly.  */
+  if (GET_CODE (operands[1]) == SYMBOL_REF
+      && !SYMBOL_REF_FUNCTION_P (operands[1]))
+    {
+      emit_move_insn (operands[0], operands[1]);
+      DONE;
+    }
+
   if (TARGET_ELF32)
     {
       rtx canonicalize_funcptr_for_compare_libfunc

Attachment: signature.asc
Description: PGP signature

Reply via email to