[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-14 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

Alan Modra  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |9.0

--- Comment #11 from Alan Modra  ---
Fixed.

[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-14 Thread amodra at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

--- Comment #10 from Alan Modra  ---
Author: amodra
Date: Fri Dec 14 09:03:50 2018
New Revision: 267123

URL: https://gcc.gnu.org/viewcvs?rev=267123=gcc=rev
Log:
[RS6000] PR88311, mlongcall indirections are optimised away

Masking CALL_LONG from the cookie was done in order to simplify and
correct length attribute calculations for indirect calls at one point
in my call series tidy when the indirect patterns used alternatives
"0,n" on the cookie operand.  (Leaving the CALL_LONG in place
calculated the wrong length for long calls without fp args.)

This is no longer necessary now that the indirect sysv call patterns
explicitly test for the fp arg bits in their length attribute
expressions.  And without the CALL_LONG to disable insns like
call_value_local_svsv, combine merrily replaces the indirect long call
sequence with a direct call.  As it should.  This patch reinstates
the CALL_LONG bit.

PR rtl-optimization/88311
* config/rs6000/rs6000.c (rs6000_call_sysv): Do not mask cookie.
(rs6000_sibcall_sysv): Likewise.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/rs6000/rs6000.c

[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-13 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

--- Comment #9 from Alan Modra  ---
Created attachment 45235
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45235=edit
fix

r266604, git 0a4b5c66df9, "[RS6000] Use standard call patterns for
__tls_get_addr calls" is the patch that regressed the long calls.  The uploaded
patch has been regression tested powerpc64le-linux with HAVE_AS_PLTCALL set. 
I'm waiting on the results of a powerpc64-linux biarch bootstrap with
HAVE_AS_PLTCALL undefined.

[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-13 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

--- Comment #8 from Iain Sandoe  ---
I don't profess to grok the intracecies of combine, but ISTM that the stored
indirection needs the moral equivalent of "used", or else it should surely be a
candidate for removal.  After all, that's a useful optimisation in other cases.

[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-13 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

--- Comment #7 from Alan Modra  ---
Hmm, it looks like combine is removing the long call.

hello2.c.262r.ud_dce:
(insn 10 9 11 2 (set (reg/f:SI 127)
(high:SI (symbol_ref:SI ("printf") [flags 0x41]  ))) "hello2.c":5:3 651 {elf_high}
 (nil))
(insn 11 10 12 2 (set (reg/f:SI 126)
(lo_sum:SI (reg/f:SI 127)
(symbol_ref:SI ("printf") [flags 0x41]  ))) "hello2.c":5:3 652 {elf_low}
 (expr_list:REG_DEAD (reg/f:SI 127)
(expr_list:REG_EQUAL (symbol_ref:SI ("printf") [flags 0x41] 
)
(nil
(insn 12 11 13 2 (set (reg:SI 66 ctr)
(reg/f:SI 126)) "hello2.c":5:3 491 {*movsi_internal1}
 (expr_list:REG_DEAD (reg/f:SI 126)
(expr_list:REG_EQUAL (symbol_ref:SI ("printf") [flags 0x41] 
)
(nil
(call_insn 13 12 18 2 (parallel [
(set (reg:SI 3 3)
(call (mem:SI (reg:SI 66 ctr) [0 __builtin_printf S4 A8])
(const_int 0 [0])))
(use (const_int 4 [0x4]))
(clobber (reg:SI 65 lr))
]) "hello2.c":5:3 658 {*call_value_indirect_nonlocal_sysvsi}
 (expr_list:REG_DEAD (reg:SI 66 ctr)
(expr_list:REG_UNUSED (reg:SI 3 3)
(expr_list:REG_CALL_DECL (symbol_ref:SI ("printf") [flags 0x41] 
)
(nil
(expr_list:SI (use (reg:SI 3 3))
(nil)))

hello2.c.263r.combine:
(note 10 9 11 2 NOTE_INSN_DELETED)
(note 11 10 12 2 NOTE_INSN_DELETED)
(note 12 11 13 2 NOTE_INSN_DELETED)
(call_insn 13 12 18 2 (parallel [
(set (reg:SI 3 3)
(call (mem:SI (symbol_ref:SI ("printf") [flags 0x41] 
) [0 __builtin_printf S4 A8])
(const_int 0 [0])))
(use (const_int 4 [0x4]))
(clobber (reg:SI 65 lr))
]) "hello2.c":5:3 659 {*call_value_nonlocal_sysvsi}
 (expr_list:REG_CALL_DECL (symbol_ref:SI ("printf") [flags 0x41] 
)
(expr_list:REG_UNUSED (reg:SI 3 3)
(nil)))
(expr_list:SI (use (reg:SI 3 3))
(nil)))

[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-13 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

Alan Modra  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC|amodra at gcc dot gnu.org, |
   |amodra at gmail dot com|
   Assignee|unassigned at gcc dot gnu.org  |amodra at gmail dot com

[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-13 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

Alan Modra  changed:

   What|Removed |Added

 CC||amodra at gmail dot com

--- Comment #6 from Alan Modra  ---
I can reproduce the problem with current gcc and auto-host.h edited to undef
HAVE_AS_PLTSEQ.  Investigating.

[Bug rtl-optimization/88311] [9 Regression] mlongcall indirections are optimised away (for binutils versions that don't support AS_PLTSEQ)

2018-12-13 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88311

Iain Sandoe  changed:

   What|Removed |Added

 CC||amodra at gcc dot gnu.org
Summary|mlongcall indirections are  |[9 Regression] mlongcall
   |optimised away  |indirections are optimised
   ||away (for binutils versions
   ||that don't support
   ||AS_PLTSEQ)

--- Comment #5 from Iain Sandoe  ---
So the reason that Segher and I were seeing different results is that I was
using the default BINUTILS on the platform (2.27) and Segher was using 2.31.

The salient difference appears to be this (from auto-host.h):
2.27   2.31
/* #undef HAVE_AS_PLTSEQ */ |   #define HAVE_AS_PLTSEQ 1

As a second point - I checked r266557 and that produces correct code with:

GNU assembler version 2.27 (ppc64-redhat-linux) using BFD version version
2.27-28.base.el7_5.1

It's possible that the patch sequence 266599-266610 could have caused this.