https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115673

--- Comment #23 from Uroš Bizjak <ubizjak at gmail dot com> ---
Comment on attachment 60337
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60337
A patch with tests

>@@ -10225,13 +10225,15 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx 
>callarg1,
>     fnaddr = gen_rtx_MEM (QImode, construct_plt_address (XEXP (fnaddr, 0)));
>   /* Since x32 GOT slot is 64 bit with zero upper 32 bits, indirect
>      branch via x32 GOT slot is OK.  */
>-  else if (!(TARGET_X32
>-           && MEM_P (fnaddr)
>-           && GET_CODE (XEXP (fnaddr, 0)) == ZERO_EXTEND
>-           && GOT_memory_operand (XEXP (XEXP (fnaddr, 0), 0), Pmode))
>-         && (sibcall
>-             ? !sibcall_insn_operand (XEXP (fnaddr, 0), word_mode)
>-             : !call_insn_operand (XEXP (fnaddr, 0), word_mode)))
>+  else if ((flag_force_indirect_call && MEM_P (faddr))
>+         || (!(TARGET_X32
>+               && MEM_P (fnaddr)
>+               && GET_CODE (XEXP (fnaddr, 0)) == ZERO_EXTEND
>+               && GOT_memory_operand (XEXP (XEXP (fnaddr, 0), 0),
>+                                      Pmode))
>+             && (sibcall
>+                 ? !sibcall_insn_operand (XEXP (fnaddr, 0), word_mode)
>+                 : !call_insn_operand (XEXP (fnaddr, 0), word_mode))))
>     {
>       fnaddr = convert_to_mode (word_mode, XEXP (fnaddr, 0), 1);
>       fnaddr = gen_rtx_MEM (QImode, copy_to_mode_reg (word_mode, fnaddr));

This part ... can we please rewrite it like:

  if (ix86_cmodel == CM_LARGE_PIC
      && !TARGET_PECOFF
      && MEM_P (fnaddr)
      && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF
      && !local_symbolic_operand (XEXP (fnaddr, 0), VOIDmode))
    fnaddr = gen_rtx_MEM (QImode, construct_plt_address (XEXP (fnaddr, 0)));
  else if (flag_force_indirect_call && MEM_P (fnaddr))
    {
      fnaddr = convert_to_mode (word_mode, XEXP (fnaddr, 0), 1);
      fnaddr = gen_rtx_MEM (QImode, copy_to_mode_reg (word_mode, fnaddr));
    }
  /* Since x32 GOT slot is 64 bit with zero upper 32 bits, indirect
     branch via x32 GOT slot is OK.  */
  else if (TARGET_X32
           && MEM_P (fnaddr)
           && GET_CODE (XEXP (fnaddr, 0)) == ZERO_EXTEND
           && GOT_memory_operand (XEXP (XEXP (fnaddr, 0), 0), Pmode))
    ;
  else if (sibcall
           ? !sibcall_insn_operand (XEXP (fnaddr, 0), word_mode)
           : !call_insn_operand (XEXP (fnaddr, 0), word_mode))
    {
      fnaddr = convert_to_mode (word_mode, XEXP (fnaddr, 0), 1);
      fnaddr = gen_rtx_MEM (QImode, copy_to_mode_reg (word_mode, fnaddr));
    }

for the sake of readability and leave to the compiler to CSE some parts by
itself?

Reply via email to