> /usr/local/gcc43/bin/g++ -v
Using built-in specs.
Target: i386-apple-darwin8.10.1
Configured with: ../gcc/configure --prefix=/usr/local/gcc43 --disable-multilib
--with-arch=pentium-m --with-tune=nocona --enable-target-optspace
--disable-bootstrap --with-gmp=/sw --with-system-zlib
--enable-languages=c,c++,objc,obj-c++
Thread model: posix
gcc version 4.3.0 20070702 (experimental)

> /usr/local/gcc43/bin/g++ -O3 -fdump-tree-final_cleanup -ffast-math 
> -fno-unswitch-loops -g -c rt-no-load-motion.cpp

Here:
<bb 15>:
  if (closest == 0)
    goto <bb 16>;
  else
    goto <bb 17>;

<bb 16>:
  res = p;
  goto <bb 19>;

<bb 17>:
  prephitmp.47 = this->sc.primcount;
  res = p;

<bb 18>:

'res = p;' is duplicated on both sides of the branch in bb 15, and should be
lifted above it.

Furthermore, if that was done, these three blocks:
<bb 9>:
  prephitmp.47 = this->sc.primcount;
  goto <bb 18>;

<bb 12>:
  prephitmp.47 = this->sc.primcount;
  goto <bb 18>;

<bb 17>:
  prephitmp.47 = this->sc.primcount;
  res = p;

<bb 18>:

would be identical. Two of them already are, but aren't merged.
(I think those prephitmp.47 statements can all be merged too, but I'm not sure
about that.)

g++ 4.1 doesn't generate so many copies; I don't remember seeing this in
earlier 4.3s either.


-- 
           Summary: [4.3 regression] Duplicate code generated on both
                    branches of if/else
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: astrange at ithinksw dot com
 GCC build triplet: i386-apple-darwin8.10.1
  GCC host triplet: i386-apple-darwin8.10.1
GCC target triplet: i386-apple-darwin8.10.1


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

Reply via email to