public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
To: Jim Wilson <wilson@redhat.com>
Cc: Alexandre Oliva <aoliva@redhat.com>, "H. J. Lu" <hjl@lucon.org>,
	"David S. Miller" <davem@redhat.com>,
	rsandifo@redhat.com, linux-mips@linux-mips.org, gcc@gcc.gnu.org,
	binutils@sources.redhat.com
Subject: Re: MIPS gas relaxation still doesn't work
Date: Wed, 16 Oct 2002 06:39:00 -0000	[thread overview]
Message-ID: <Pine.GSO.3.96.1021016124113.14774D-100000@delta.ds2.pg.gda.pl> (raw)
In-Reply-To: <xwun0pfwcy1.fsf@tonopah.toronto.redhat.com>

On 15 Oct 2002, Jim Wilson wrote:

> There is a natural conflict between compiler optimization and assembler
> optimization/assembler macro expansion.  If you want the best possible
> compiler optimization, then you need to be willing to give up use of
> assembler optimizations and assembler macros.  That includes uses in extended
> asms.  We can make that work if we have to, but it is better if we don't have
> to.

 If gcc can fully handle all possible cases that gas does, I see no
problem.  That may be beneficial if done well, but will require care to
track changes done to both code generation engines to make sure they are
in sync.  If gcc keeps the recent good habit of frequent releases, then
it's perfecty acceptable.

> This is ISA confusion.  When you ask gas to generate o32/PIC code, it assumes
> the least common denominator, which is the R2000.  The R2000 does not have
> hardware interlocks on loads.  It requires a nop in between a load and the
> instruction that uses the result of the load.  Therefore, we can not put a
> load in a delay slot unless we know that the instruction at the branch target
> does not use the result of the load.  Since gas doesn't bother to construct
> a control flow graph, we have no idea what is at the branch target, and
> therefore we can't put a load in the branch delay slot.

 I'm sorry, I missed the load delay slot property first and only some time
later I recalled it (shame on me -- I even own an R3k system ;-) ).  Still
for "-mips2" the code is not exactly perfect:

la2.o:     file format elf32-tradlittlemips

Disassembly of section .text:

00000000 <bar>:
   0:	8f820000 	lw	v0,0(gp)
			0: R_MIPS_GOT16	foo
   4:	00000000 	nop
   8:	1000fffd 	b	0 <bar>
   c:	8c420000 	lw	v0,0(v0)

The "nop" is unnecessary.

> It can be optimized if we use direct cpu instructions instead of relying
> on assembler macros.  Then gcc would know about the load instructions, and
> would be able to place one in the branch delay slot (assuming a R4000 or
> better target).

 To nitpick, actually an R6000 suffices. ;-)

> The MIPS gcc target is the only one that has this problem, because it is the
> only one that relies on assembler macros for PIC support.

 So it does for non-PIC.

> Yes it can hurt.  If gcc decides the optimal code for a loop requires putting
> a nop in a branch delay slot, then the assembler would hurt performance if
> it put another instruction there.

 Once it only emits machine instructions and it can really judge the "nop"
is a win -- I agree.  Still it may emit ".set reorder; .set macro" if it
cannot judge for some reason.

> If your main concern is only extended asm code writting using assembler macros,
> then that can be fixed by turning on assembler optimization within the
> extended asm code.  In the long run though, you are better off if you stop
> using assembler macros.

 As soon as gcc supports plain machine instructions well, as I wrote in
another mail, I see no showstopper problems.  Though putting a "nop" 
surrounded with an "ifdef" clause in all load delay slots you cannot
usefully fill is not nice -- maybe a "%" code could be added to gcc to let
an assembly programmer express these "nop" fillers in a way gcc would know
about them and be able to remove them if unneeded. 

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

  reply	other threads:[~2002-10-16 11:03 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20021012113423.A27894@lucon.org>
     [not found] ` <20021013145423.A10174@lucon.org>
2002-10-14  9:23   ` H. J. Lu
2002-10-14  9:35     ` Richard Sandiford
2002-10-14  9:37       ` H. J. Lu
2002-10-14 10:04         ` Richard Sandiford
2002-10-14 10:43           ` H. J. Lu
2002-10-14 10:50             ` David S. Miller
2002-10-14 10:53               ` H. J. Lu
2002-10-14 11:13             ` Alexandre Oliva
2002-10-14 11:21               ` H. J. Lu
2002-10-14 12:28                 ` Alexandre Oliva
2002-10-14 12:37                   ` H. J. Lu
2002-10-14 12:58                     ` Alexandre Oliva
2002-10-14 13:00                       ` H. J. Lu
2002-10-14 13:08                         ` David S. Miller
2002-10-14 13:23                           ` H. J. Lu
2002-10-14 14:04                             ` David S. Miller
2002-10-14 14:14                               ` H. J. Lu
2002-10-14 14:17                                 ` Alexandre Oliva
2002-10-14 14:18                                   ` H. J. Lu
2002-10-14 15:37                                     ` Alexandre Oliva
2002-10-14 15:40                                       ` H. J. Lu
2002-10-15  1:08                                         ` Alexandre Oliva
2002-10-15  2:53                                           ` Dominic Sweetman
2002-10-15  8:12                                             ` Alexandre Oliva
2002-10-15 14:18                                             ` Jim Wilson
2002-10-15 13:27                                           ` Maciej W. Rozycki
2002-10-15 16:37                                             ` Jim Wilson
2002-10-16  6:39                                               ` Maciej W. Rozycki [this message]
2002-10-16 10:38                                                 ` Jim Wilson
2002-10-15 18:40                                             ` Alexandre Oliva
2002-10-16  7:01                                               ` Maciej W. Rozycki
2002-10-16  7:47                                                 ` Alexandre Oliva
2002-10-16  8:06                                                   ` Maciej W. Rozycki
2002-10-14 17:02                                     ` Eric Christopher
2002-10-15  1:15                                       ` Alexandre Oliva
2002-10-14 14:44                                   ` Michael Matz
2002-10-15 13:28                         ` Jim Wilson
2002-10-15 13:45                           ` Paul Koning
2002-10-15 14:32                             ` Maciej W. Rozycki
2002-10-15 15:33                               ` Alexandre Oliva
2002-10-16  5:32                                 ` Maciej W. Rozycki
2002-10-15 14:00                           ` Daniel Jacobowitz
2002-10-15 14:56                             ` Eric Christopher
2002-10-15 15:05                               ` Daniel Jacobowitz
2002-10-16  7:53                                 ` Paul Koning
2002-10-16  8:11                                   ` Maciej W. Rozycki
2002-10-15 15:23                             ` Jim Wilson
2002-10-16  5:38                               ` Maciej W. Rozycki
2002-10-16 10:37                                 ` Jim Wilson
2002-10-16 11:04                                   ` Maciej W. Rozycki
2002-10-15 16:54                         ` Richard Henderson
2002-10-14  9:40     ` Alexandre Oliva
2002-10-14  9:44       ` H. J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.3.96.1021016124113.14774D-100000@delta.ds2.pg.gda.pl \
    --to=macro@ds2.pg.gda.pl \
    --cc=aoliva@redhat.com \
    --cc=binutils@sources.redhat.com \
    --cc=davem@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=hjl@lucon.org \
    --cc=linux-mips@linux-mips.org \
    --cc=rsandifo@redhat.com \
    --cc=wilson@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).