public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/7325: Test "if ( a && b )" where a, b are 1-bit fields, could be better
@ 2003-01-08  1:51 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-01-08  1:51 UTC (permalink / raw)
  To: falk, gcc-bugs, gcc-prs, nobody

Synopsis: Test "if ( a && b )" where a, b are 1-bit fields, could be better

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Tue Jan  7 17:51:49 2003
State-Changed-Why:
    The code generated by 3.4 is more complex with a lot
    of jumping around, but the issue basically still applies.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7325


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

* Re: optimization/7325: Test "if ( a && b )" where a, b are 1-bit fields, could be better
@ 2003-01-14 14:46 reichelt
  0 siblings, 0 replies; 3+ messages in thread
From: reichelt @ 2003-01-14 14:46 UTC (permalink / raw)
  To: falk, gcc-bugs, gcc-prs, nobody

Synopsis: Test "if ( a && b )" where a, b are 1-bit fields, could be better

State-Changed-From-To: analyzed->closed
State-Changed-By: reichelt
State-Changed-When: Tue Jan 14 06:46:51 2003
State-Changed-Why:
    There seems to be not much room for improvement, given the reply below:
    
    > Yeah :( I had this exact same conversation with the last guy the
    > bug was assigned to.  I wish I'd kept my notes from then.
    > 
    > Let's see, we were trying to determine if the test
    > 
    >        (*foo & 3) == 3
    > 
    > could be optimized.  At the time, I think we concluded that translating to
    > 
    >        (~*foo & 3) == 0
    > 
    > which was sometimes, but usually not, an improvement.
    > 
    >        -ed falk

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7325


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

* Re: optimization/7325: Test "if ( a && b )" where a, b are 1-bit fields, could be better
@ 2003-01-08 16:16 Volker Reichelt
  0 siblings, 0 replies; 3+ messages in thread
From: Volker Reichelt @ 2003-01-08 16:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR optimization/7325; it has been noted by GNATS.

From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, falk@efalk.org
Cc: bangerth@dealii.org
Subject: Re: optimization/7325: Test "if ( a && b )" where a, b are 1-bit fields, could be better
Date: Wed, 8 Jan 2003 18:12:59 +0100

 falk@efalk.org wrote:
 
 > However, if the test is
 >
 >    if( foo->f1 && foo->f2 ) { ... }
 >
 > The code generated is
 >
 >    if( (*foo & 3) == 3 ) { ... }
 >
 > which compiles as
 >
 >    movb (%ebx), %al
 >    andl $3, %eax
 >    cmpb $3, %al
 >    jne .L34
 >    ...
 >
 > which is not so hot.
 >
 > It would be better if the test was translated to
 >
 >    if( (*foo & ~3) == 0 ) { ... }
 >
 
 Argghh! This is just plain wrong! You are testing all the undefined bits
 and not the relevant ones!
 
 You could translate the test to
 
    if( (*foo | ~3) == ~0 ) { ... }
 
 which translates to
 
    if( ~(*foo | ~3) == 0 ) { ... }
 
 or something like this (modulo signed/unsigned issues)
 
    if( (*foo | ~3)+1 == 0 ) { ... }
 
 I don't know if one of those can be translated into faster code
 than currently generated.
 
 Regards,
 Volker
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7325
 
 


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

end of thread, other threads:[~2003-01-14 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-08  1:51 optimization/7325: Test "if ( a && b )" where a, b are 1-bit fields, could be better bangerth
2003-01-08 16:16 Volker Reichelt
2003-01-14 14:46 reichelt

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