public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/17102] New: Missed constant folding opportunity
@ 2004-08-19 14:59 gcc-bugzilla at gcc dot gnu dot org
  2004-08-19 15:14 ` [Bug other/17102] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ 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 illustrated.    Duplicate using gcc 3.5 and
command line:

gcc -O3 -m64 -c test.c


Testcase:
#include "stdio.h"
const int C0 = 0;
const int C1 = 1;
const int C2 = 2;

void bar () {
  printf("bar\n");
}

void foo ()
{
  /* GCC is able to figure this one out, do constant
     folding and dead code elimination, and eliminate
     the entire block of code */
  if (1, 2, 0) bar ();

  /* .. it unsuccessfully resolves this one. */
  if (C1, C2, C0) bar ();
}

Assembly:
.foo:
      mflr 0
      ld 9,.LC2@toc(2)
      std 0,16(1)
      lwz 0,0(9)
      stdu 1,-112(1)
      cmpwi 7,0,0
      bne- 7,.L6
      addi 1,1,112
      ld 0,16(1)
      mtlr 0
      blr
.L6:
      ld 3,.LC3@toc(2)
      bl .puts
      nop
      addi 1,1,112
      ld 0,16(1)
      mtlr 0
      blr



-- 
           Summary: Missed constant folding opportunity
           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=17102


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

* [Bug other/17102] Missed constant folding opportunity
  2004-08-19 14:59 [Bug other/17102] New: Missed constant folding opportunity gcc-bugzilla at gcc dot gnu dot org
@ 2004-08-19 15:14 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-19 15:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-19 15:14 -------
Fixed between 20040721  and 20040725.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |missed-optimization
         Resolution|                            |FIXED
   Target Milestone|---                         |3.5.0


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


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

end of thread, other threads:[~2004-08-19 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-19 14:59 [Bug other/17102] New: Missed constant folding opportunity gcc-bugzilla at gcc dot gnu dot org
2004-08-19 15:14 ` [Bug other/17102] " pinskia 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).