public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/17107] New: Opportunity to improve code generated for complex logical expression
@ 2004-08-19 14:59 gcc-bugzilla at gcc dot gnu dot org
  2004-08-19 15:29 ` [Bug rtl-optimization/17107] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-08-19 14:59 UTC (permalink / raw)
  To: gcc-bugs

Description:
A non-optimal code sequence is illustraded.    Duplicate using gcc 3.5 and
command line:

gcc -O3 -m64 -c test.c


Testcase:
int i;
void foo(int a, int b, int c) {

  i = (a > b && a < c);

}

Assembly:
Currently gcc 3.5 generates the following code which always results
in the execution of the compare/branch for the right side of the
expression (i.e. a < c):

.foo:
      cmpw 7,4,3
      cmpw 6,3,5
      ld 11,.LC0@toc(2)
      li 9,1
      blt- 7,.L2
      li 9,0
.L2:
      li 0,1
      blt- 6,.L3
      li 0,0
.L3:
      and 0,9,0
      stw 0,0(11)
      blr

Execution of the second compare/branch may be avoided by
restructuring the code.  This also eliminates the need for
the 'and':

.foo:
      cmpw 7,4,3
      ld 11,.LC0@toc(2)
      li 9,0
      bng- 7,.L2
      cmpw 6,3,5
      bnl- 6,.L2
      li 9,1
.L2:
      stw 9,0(11)
      blr



-- 
           Summary: Opportunity to improve code generated for complex
                    logical expression
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P1
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steinmtz at us dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm
                    dot com
 GCC build triplet: powerpc64-linux
  GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17107


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

end of thread, other threads:[~2004-12-01 17:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-19 14:59 [Bug other/17107] New: Opportunity to improve code generated for complex logical expression gcc-bugzilla at gcc dot gnu dot org
2004-08-19 15:29 ` [Bug rtl-optimization/17107] " pinskia at gcc dot gnu dot org
2004-10-12 10:38 ` nathan at gcc dot gnu dot org
2004-11-12 14:48 ` nathan at gcc dot gnu dot org
2004-11-15  2:39 ` pinskia at gcc dot gnu dot org
2004-11-18 12:11 ` cvs-commit at gcc dot gnu dot org
2004-11-18 12:14 ` nathan at gcc dot gnu dot org
2004-11-18 12:16 ` pinskia at gcc dot gnu dot org
2004-12-01 17:19 ` cvs-commit at gcc dot gnu dot org

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