public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Using shifts by 1 on K6,K7 and i386
@ 2000-07-01  2:31 Martin Erhardsen
  2000-07-05 18:05 ` Jeffrey A Law
  2000-07-06 17:24 ` Richard Henderson
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Erhardsen @ 2000-07-01  2:31 UTC (permalink / raw)
  To: gcc

Why doesn't gcc use logical shifts, arithmetric shifts and rotates by 1 
instead of immediate operands on the K6,K7 and i386.
It saves a byte and has the same latency (except on i486, 
where it uses an extra cycle). I have measured this on 
my K6-2 and looked it up for K7 and i386
I propose that the current predicate for using shifts 
and rotates by 1

(TARGET_PENTIUM || TARGET_PENTIUMPRO)

be replaced by this

(!TARGET_I486 || optimize_size)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Using shifts by 1 on K6,K7 and i386
  2000-07-01  2:31 Using shifts by 1 on K6,K7 and i386 Martin Erhardsen
@ 2000-07-05 18:05 ` Jeffrey A Law
  2000-07-06  2:20   ` Martin Erhardsen
  2000-07-06 17:24 ` Richard Henderson
  1 sibling, 1 reply; 6+ messages in thread
From: Jeffrey A Law @ 2000-07-05 18:05 UTC (permalink / raw)
  To: Martin Erhardsen; +Cc: gcc

  In message < 000701bfe33f$1e751e60$b495f9c3@mincomputer >you write:
  > Why doesn't gcc use logical shifts, arithmetric shifts and rotates by 1 
  > instead of immediate operands on the K6,K7 and i386.
Because nobody's told us what is best for this case on the K6, K7 and
i386.

  > It saves a byte and has the same latency (except on i486, 
  > where it uses an extra cycle). I have measured this on 
  > my K6-2 and looked it up for K7 and i386
OK.

  > I propose that the current predicate for using shifts 
  > and rotates by 1
So, submit a patch which changes i386.md appropriately.

THanks,
jeff


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Using shifts by 1 on K6,K7 and i386
  2000-07-05 18:05 ` Jeffrey A Law
@ 2000-07-06  2:20   ` Martin Erhardsen
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Erhardsen @ 2000-07-06  2:20 UTC (permalink / raw)
  To: law; +Cc: gcc

----- Original Message ----- 
From: "Jeffrey A Law" <law@cygnus.com>
To: "Martin Erhardsen" <MartinErhardsen@mail.tele.dk>
Cc: <gcc@gcc.gnu.org>
Sent: Thursday, July 06, 2000 3:06 AM
Subject: Re: Using shifts by 1 on K6,K7 and i386 


> 
>   In message < 000701bfe33f$1e751e60$b495f9c3@mincomputer >you write:
>   > Why doesn't gcc use logical shifts, arithmetric shifts and rotates by 1 
>   > instead of immediate operands on the K6,K7 and i386.
> Because nobody's told us what is best for this case on the K6, K7 and
> i386.
> 
>   > It saves a byte and has the same latency (except on i486, 
>   > where it uses an extra cycle). I have measured this on 
>   > my K6-2 and looked it up for K7 and i386
> OK.
> 
>   > I propose that the current predicate for using shifts 
>   > and rotates by 1
> So, submit a patch which changes i386.md appropriately.

Okay, I'll check the documentation for the intel processors 
to make sure that this is the right thing to do for those processors 
too, and then I'll start writing my patch.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Using shifts by 1 on K6,K7 and i386
  2000-07-01  2:31 Using shifts by 1 on K6,K7 and i386 Martin Erhardsen
  2000-07-05 18:05 ` Jeffrey A Law
@ 2000-07-06 17:24 ` Richard Henderson
  2000-07-07  6:01   ` Martin Erhardsen
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2000-07-06 17:24 UTC (permalink / raw)
  To: Martin Erhardsen; +Cc: gcc

On Sat, Jul 01, 2000 at 11:30:56AM +0200, Martin Erhardsen wrote:
> I propose that the current predicate for using shifts 
> and rotates by 1
> 
> (TARGET_PENTIUM || TARGET_PENTIUMPRO)
> 
> be replaced by this
> 
> (!TARGET_I486 || optimize_size)

Actaully, if any change is made, it should be of the form
`TARGET_USE_SHIFT1', much like the existing TARGET_USE_LEAVE
and friends.


r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Using shifts by 1 on K6,K7 and i386
  2000-07-06 17:24 ` Richard Henderson
@ 2000-07-07  6:01   ` Martin Erhardsen
  2000-07-17  2:34     ` Jeffrey A Law
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Erhardsen @ 2000-07-07  6:01 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

----- Original Message ----- 
From: "Richard Henderson" <rth@cygnus.com>
To: "Martin Erhardsen" <MartinErhardsen@mail.tele.dk>
Cc: <gcc@gcc.gnu.org>
Sent: Friday, July 07, 2000 2:24 AM
Subject: Re: Using shifts by 1 on K6,K7 and i386


> On Sat, Jul 01, 2000 at 11:30:56AM +0200, Martin Erhardsen wrote:
> > I propose that the current predicate for using shifts 
> > and rotates by 1
> > 
> > (TARGET_PENTIUM || TARGET_PENTIUMPRO)
> > 
> > be replaced by this
> > 
> > (!TARGET_I486 || optimize_size)
> 
> Actaully, if any change is made, it should be of the form
> `TARGET_USE_SHIFT1', much like the existing TARGET_USE_LEAVE
> and friends.
> 

I have looked at the 486 manual, and it is not that simple. Shifts by one are 
slower only when using register operands on the 486. This means that the 
ideally the predicate should be something like this

(!(TARGET_I486 && register_operand(operands[0],SImode)) || optimize_size)

I'm not sure what the second operand to memory_operand does and if it is 
necessary, but I would need at least one operand to a TARGET_USE_SHIFT1
macro.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Using shifts by 1 on K6,K7 and i386
  2000-07-07  6:01   ` Martin Erhardsen
@ 2000-07-17  2:34     ` Jeffrey A Law
  0 siblings, 0 replies; 6+ messages in thread
From: Jeffrey A Law @ 2000-07-17  2:34 UTC (permalink / raw)
  To: Martin Erhardsen; +Cc: Richard Henderson, gcc

  In message < 006c01bfe813$524c0680$3595f9c3@mincomputer >you write:
  > > Actaully, if any change is made, it should be of the form
  > > `TARGET_USE_SHIFT1', much like the existing TARGET_USE_LEAVE
  > > and friends.
Richard is correct here.

  > I have looked at the 486 manual, and it is not that simple. Shifts by one
  > are slower only when using register operands on the 486. This means that
  > the ideally the predicate should be something like this
  > 
  > (!(TARGET_I486 && register_operand(operands[0],SImode)) || optimize_size)
  > 
  > I'm not sure what the second operand to memory_operand does and if it is 
  > necessary, but I would need at least one operand to a TARGET_USE_SHIFT1
  > macro.
The second operand to "register_operand" is the mode of the operand.  In this
case it should be the mode of the value that you want to shift.

Instead of using SImode, just use GET_MODE (operands[0]) for the second
argument.

Yes, you'll need to make the TARGET_USE_SHIFT1 change like Richard suggested
too -- and if you need an argument, that's not a problem either.  There's no
reason that the new TARGET_USE_SHIFT1 couldn't accept an argument that I'm
aware of.


jeff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-07-17  2:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-01  2:31 Using shifts by 1 on K6,K7 and i386 Martin Erhardsen
2000-07-05 18:05 ` Jeffrey A Law
2000-07-06  2:20   ` Martin Erhardsen
2000-07-06 17:24 ` Richard Henderson
2000-07-07  6:01   ` Martin Erhardsen
2000-07-17  2:34     ` Jeffrey A Law

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).