public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/43892]  New: PowerPC suboptimal "add with carry" optimization
@ 2010-04-26 13:33 gcc-bugzilla at gcc dot gnu dot org
  2010-04-26 13:39 ` [Bug rtl-optimization/43892] " jakub at gcc dot gnu dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 40+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2010-04-26 13:33 UTC (permalink / raw)
  To: gcc-bugs


PowerPC suboptimal "add with carry" optimization

Environment:
System: Linux gentoo-jocke 2.6.31-gentoo-r6 #1 SMP PREEMPT Sun Feb 28 22:54:53
CET 2010 i686 Intel(R) Core(TM)2 Duo CPU E8500 @ 3.16GHz GenuineIntel GNU/Linux



host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /var/tmp/portage/sys-devel/gcc-4.3.4/work/gcc-4.3.4/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.4
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--disable-fixed-point --enable-nls --without-included-gettext
--with-system-zlib --disable-checking --disable-werror --enable-secureplt
--disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp
--disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/
--with-pkgversion='Gentoo 4.3.4 p1.0, pie-10.1.5'

How-To-Repeat:
Noticed that gcc 4.3.4 doesn't optimize "add with carry" properly:

static u32
add32carry(u32 sum, u32 x)
{
  u32 z = sum + x;
  if (sum + x < x)
      z++;
  return z;
}
Becomes:
add32carry:
        add 3,3,4
        subfc 0,4,3
        subfe 0,0,0
        subfc 0,0,3
        mr 3,0
Instead of:
        addc 3,3,4
        addze 3,3

This slows down the the Internet checksum sigificantly

Also, doing this in a loop can be further optimized:

for(;len; --len)
   sum = add32carry(sum, *++buf);


        addic 3, 3, 0 /* clear carry */
.L31:
        lwzu 0,4(9)
        adde 3, 3, 0 /* add with carry */
        bdnz .L31

        addze 3, 3 /* add in final carry */


------- Comment #1 from joakim dot tjernlund at transmode dot se  2010-04-26 13:33 -------
Fix:
        None


-- 
           Summary: PowerPC suboptimal "add with carry" optimization
           Product: gcc
           Version: 4.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: joakim dot tjernlund at transmode dot se
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 40+ messages in thread
[parent not found: <bug-43892-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2023-08-29 17:43 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-26 13:33 [Bug rtl-optimization/43892] New: PowerPC suboptimal "add with carry" optimization gcc-bugzilla at gcc dot gnu dot org
2010-04-26 13:39 ` [Bug rtl-optimization/43892] " jakub at gcc dot gnu dot org
2010-04-26 13:53 ` dje at gcc dot gnu dot org
2010-04-26 13:54 ` dje at gcc dot gnu dot org
2010-04-26 13:59 ` joakim dot tjernlund at transmode dot se
2010-04-26 14:43 ` rguenth at gcc dot gnu dot org
2010-04-26 15:19 ` joakim dot tjernlund at transmode dot se
2010-05-20 12:14 ` [Bug regression/43892] " joakim dot tjernlund at transmode dot se
2010-05-20 14:25 ` dje at gcc dot gnu dot org
2010-05-20 14:48 ` joakim dot tjernlund at transmode dot se
2010-05-21  0:28 ` dje at gcc dot gnu dot org
2010-05-21  6:23 ` joakim dot tjernlund at transmode dot se
2010-05-21 17:42 ` [Bug target/43892] " segher at gcc dot gnu dot org
2010-05-25 21:42 ` joakim dot tjernlund at transmode dot se
2010-05-26 16:46 ` segher at kernel dot crashing dot org
2010-05-26 20:47 ` joakim dot tjernlund at transmode dot se
2010-05-27  1:37 ` dje at gcc dot gnu dot org
2010-05-27  7:33 ` joakim dot tjernlund at transmode dot se
     [not found] <bug-43892-4@http.gcc.gnu.org/bugzilla/>
2010-09-29 12:45 ` joakim.tjernlund at transmode dot se
2015-01-18 16:34 ` segher at gcc dot gnu.org
2015-01-18 17:00 ` joakim.tjernlund at transmode dot se
2015-01-18 20:31 ` segher at gcc dot gnu.org
2015-01-18 21:44 ` joakim.tjernlund at transmode dot se
2015-01-18 22:54 ` segher at gcc dot gnu.org
2015-01-19  0:05 ` joakim.tjernlund at transmode dot se
2020-10-20 18:37 ` christophe.leroy at csgroup dot eu
2020-10-20 18:59 ` segher at gcc dot gnu.org
2020-10-20 19:37 ` joakim.tjernlund at infinera dot com
2020-10-21  6:09 ` christophe.leroy at csgroup dot eu
2020-10-21 19:28 ` segher at gcc dot gnu.org
2020-10-21 21:01 ` jakub at gcc dot gnu.org
2020-10-21 21:31 ` segher at gcc dot gnu.org
2021-06-03  1:50 ` pinskia at gcc dot gnu.org
2021-06-03  4:33 ` segher at gcc dot gnu.org
2021-06-03  7:00 ` joakim.tjernlund at infinera dot com
2021-06-03 19:32 ` segher at gcc dot gnu.org
2021-12-03 19:44 ` roger at nextmovesoftware dot com
2023-06-06 20:14 ` jakub at gcc dot gnu.org
2023-08-29 16:41 ` bergner at gcc dot gnu.org
2023-08-29 17:43 ` roger at nextmovesoftware dot com

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