public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Three old entries from PROBLEMS
@ 2009-11-01 23:41 Gerald Pfeifer
  2009-11-02  0:04 ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Gerald Pfeifer @ 2009-11-01 23:41 UTC (permalink / raw)
  To: gcc

At http://gcc.gnu.org/projects/#the_old_problems_file we have a short
list coming from the GCC 2 PROBLEMS file.  Instead of carrying this
around forever, I am wondering whether we could quickly review these
and either remove (as not applicable any longer) or move to Bugzilla?

  <li value="110">Possible special combination pattern: If the two
  operands to a comparison die there and both come from insns that are
  identical except for replacing one operand with the other, throw away
  those insns.  Ok if insns being discarded are known 1 to 1.  An andl
  #1 after a seq is 1 to 1, but how should compiler know that?</li>
 
  <li value="117">Any number of slow zero-extensions in one loop, that
  have their clr insns moved out of the loop, can share one register if
  their original life spans are disjoint.  But it may be hard to be sure
  of this since the life span data that regscan produces may be hard to
  interpret validly or may be incorrect after cse.</li>

  <li value="118">In cse, when a bfext insn refers to a register, if the
  field corresponds to a halfword or a byte and the register is
  equivalent to a memory location, it would be possible to detect this
  and replace it with a simple memory reference.</li>

I'll be glad to take care of it, provided guidance from subject matter
experts what to do about these three.

Gerald

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

* Re: Three old entries from PROBLEMS
  2009-11-01 23:41 Three old entries from PROBLEMS Gerald Pfeifer
@ 2009-11-02  0:04 ` Paolo Bonzini
  2009-11-02  7:46   ` Joern Rennecke
  2009-11-02 17:37   ` Richard Henderson
  0 siblings, 2 replies; 7+ messages in thread
From: Paolo Bonzini @ 2009-11-02  0:04 UTC (permalink / raw)
  To: gcc


>    <li value="110">Possible special combination pattern: If the two
>    operands to a comparison die there and both come from insns that are
>    identical except for replacing one operand with the other, throw away
>    those insns.  Ok if insns being discarded are known 1 to 1.  An andl
>    #1 after a seq is 1 to 1, but how should compiler know that?</li>

That would be:

add r4, r1, r2  (or sub by inverting the compare operands, or xor
                  if used in an equality/inequality comparison)
add r5, r1, r3
cmp r4, r5      -> cmp r2, r3

We don't do this, but it doesn't seem hard to do on the tree level (e.g. 
in reassoc) or in combine for -fstrict-overflow.  Nice trick, worth a 
Bugzilla entry IMO.

I don't understand the last sentence.

>    <li value="117">Any number of slow zero-extensions in one loop, that
>    have their clr insns moved out of the loop, can share one register if
>    their original life spans are disjoint.  But it may be hard to be sure
>    of this since the life span data that regscan produces may be hard to
>    interpret validly or may be incorrect after cse.</li>

That would be:

clr r7
clr r8
...
move strict-low-part(r7), r0
...
move strict-low-part(r8), r1 --> could reuse r7

This is not implemented but IMHO obsolete, most of the targets will just 
use an AND to implement zero extension.

>    <li value="118">In cse, when a bfext insn refers to a register, if the
>    field corresponds to a halfword or a byte and the register is
>    equivalent to a memory location, it would be possible to detect this
>    and replace it with a simple memory reference.</li>

I think we do this in combine now.

Paolo

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

* Re: Three old entries from PROBLEMS
  2009-11-02  0:04 ` Paolo Bonzini
@ 2009-11-02  7:46   ` Joern Rennecke
  2009-11-02  7:57     ` Joern Rennecke
  2009-11-02 10:07     ` Paolo Bonzini
  2009-11-02 17:37   ` Richard Henderson
  1 sibling, 2 replies; 7+ messages in thread
From: Joern Rennecke @ 2009-11-02  7:46 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc

Quoting Paolo Bonzini <bonzini@gnu.org>:

>
>>   <li value="110">Possible special combination pattern: If the two
>>   operands to a comparison die there and both come from insns that are
>>   identical except for replacing one operand with the other, throw away
>>   those insns.  Ok if insns being discarded are known 1 to 1.  An andl
>>   #1 after a seq is 1 to 1, but how should compiler know that?</li>
>
> That would be:
>
> add r4, r1, r2  (or sub by inverting the compare operands, or xor
>                  if used in an equality/inequality comparison)
> add r5, r1, r3
> cmp r4, r5      -> cmp r2, r3
>
> We don't do this, but it doesn't seem hard to do on the tree level
> (e.g. in reassoc) or in combine for -fstrict-overflow.  Nice trick,
> worth a Bugzilla entry IMO.

This would only be valid if the comparison is in an equality context
(or for special input operand ranges).
So (unless the target is CC0) you'd either have to use dataflow analysis
to look at all the contexts the comparison result is used in, or you'd need
a target hook to classify CCmode modes to check if they are used only
for equality comparisons and can have their inputs altered.

> I don't understand the last sentence.
>
>>   <li value="117">Any number of slow zero-extensions in one loop, that
>>   have their clr insns moved out of the loop, can share one register if
>>   their original life spans are disjoint.  But it may be hard to be sure
>>   of this since the life span data that regscan produces may be hard to
>>   interpret validly or may be incorrect after cse.</li>
>
> That would be:
>
> clr r7
> clr r8
> ...
> move strict-low-part(r7), r0
> ...
> move strict-low-part(r8), r1 --> could reuse r7
>
> This is not implemented but IMHO obsolete, most of the targets will
> just use an AND to implement zero extension.

If the target can actually write to partial registers and refer to the
entire register without undue delay, you won't need and zero_extend or
AND operation at all.  So this is obsolete only to the extent that such
targets have become fewer / more arcane.
FWIW the ARC mxp had that feature, but it doesn't look like that port
will get into gcc mainline.

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

* Re: Three old entries from PROBLEMS
  2009-11-02  7:46   ` Joern Rennecke
@ 2009-11-02  7:57     ` Joern Rennecke
  2009-11-02 10:07     ` Paolo Bonzini
  1 sibling, 0 replies; 7+ messages in thread
From: Joern Rennecke @ 2009-11-02  7:57 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: Paolo Bonzini, gcc

Quoting Joern Rennecke <amylaar@spamcop.net>:

> Quoting Paolo Bonzini <bonzini@gnu.org>:
...
>> That would be:
>>
>> clr r7
>> clr r8
>> ...
>> move strict-low-part(r7), r0
>> ...
>> move strict-low-part(r8), r1 --> could reuse r7
>>
>> This is not implemented but IMHO obsolete, most of the targets will
>> just use an AND to implement zero extension.
>
> If the target can actually write to partial registers and refer to the
> entire register without undue delay, you won't need and zero_extend or
> AND operation at all.  So this is obsolete only to the extent that such
> targets have become fewer / more arcane.
> FWIW the ARC mxp had that feature, but it doesn't look like that port
> will get into gcc mainline.

P.S.: more common in contemporary targets is the availability of vector
operations.  In order to use these to save zero extensions, instead of  
the result register you need the inputs to be prepared with a zero  
highpart.
E.g. to do a loop with an unsigned short biv, you zero-extend the initial
biv value and the loop increment value, then use a vector add for the biv
increment operation.

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

* Re: Three old entries from PROBLEMS
  2009-11-02  7:46   ` Joern Rennecke
  2009-11-02  7:57     ` Joern Rennecke
@ 2009-11-02 10:07     ` Paolo Bonzini
  1 sibling, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2009-11-02 10:07 UTC (permalink / raw)
  To: Joern Rennecke; +Cc: gcc

On 11/02/2009 08:49 AM, Joern Rennecke wrote:
>
> This would only be valid if the comparison is in an equality context
> (or for special input operand ranges).
> So (unless the target is CC0) you'd either have to use dataflow analysis
> to look at all the contexts the comparison result is used in, or you'd need
> a target hook to classify CCmode modes to check if they are used only
> for equality comparisons and can have their inputs altered.

Yes, that's why I suggested doing it on the tree level instead.

>> This is not implemented but IMHO obsolete, most of the targets will
>> just use an AND to implement zero extension.
>
> If the target can actually write to partial registers and refer to the
> entire register without undue delay, you won't need and zero_extend or
> AND operation at all.  So this is obsolete only to the extent that such
> targets have become fewer / more arcane.

Yes, that's what I meant.  The implementation effort is much less justified.

Paolo

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

* Re: Three old entries from PROBLEMS
  2009-11-02  0:04 ` Paolo Bonzini
  2009-11-02  7:46   ` Joern Rennecke
@ 2009-11-02 17:37   ` Richard Henderson
  2009-11-02 17:48     ` Richard Henderson
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2009-11-02 17:37 UTC (permalink / raw)
  To: gcc

On 11/01/2009 04:03 PM, Paolo Bonzini wrote:
>
>> An andl
>> #1 after a seq is 1 to 1, but how should compiler know that?</li>
>
> I don't understand the last sentence.

I think it's talking about something like

int f(int x, int y)
{
   int r;
   r = x == y;
   r &= 1;
   return r;
}

	cmpl	%esi, %edi
	sete	%al
	andl	$1, %eax

Not the most ideal way to zero-extend the return value, from a partial 
register stall point of view.  Note that with char values, we do 
eliminate the AND operation, so this is not (any longer) about some pass 
not understanding STORE_FLAG_VALUE.


r~

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

* Re: Three old entries from PROBLEMS
  2009-11-02 17:37   ` Richard Henderson
@ 2009-11-02 17:48     ` Richard Henderson
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2009-11-02 17:48 UTC (permalink / raw)
  To: gcc

On 11/02/2009 09:37 AM, Richard Henderson wrote:
> Note that with char values, we do
> eliminate the AND operation, so this is not (any longer) about some pass
> not understanding STORE_FLAG_VALUE.

... or maybe it is.  We probably should have eliminated the AND at the 
gimple level.


r~

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

end of thread, other threads:[~2009-11-02 17:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-01 23:41 Three old entries from PROBLEMS Gerald Pfeifer
2009-11-02  0:04 ` Paolo Bonzini
2009-11-02  7:46   ` Joern Rennecke
2009-11-02  7:57     ` Joern Rennecke
2009-11-02 10:07     ` Paolo Bonzini
2009-11-02 17:37   ` Richard Henderson
2009-11-02 17:48     ` Richard Henderson

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