public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "joakim.tjernlund at infinera dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/43892] PowerPC suboptimal "add with carry" optimization
Date: Thu, 03 Jun 2021 07:00:16 +0000	[thread overview]
Message-ID: <bug-43892-4-TGNuWWkuie@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-43892-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #34 from Joakim Tjernlund <joakim.tjernlund at infinera dot com> ---
(In reply to Christophe Leroy from comment #28)
> Looks like we have a way to do it. Works at least with GCC 5.5, 8.2, 9.2,
> 10.1
> 
> unsigned long g(unsigned long a, unsigned long b)
> {
> 	unsigned long long s = (unsigned long long)a + (unsigned long long)b;
> 
> 	return (s >> 32) + s;
> }
> 
> 00000020 <g>:
>   20:	7c 63 20 14 	addc    r3,r3,r4
>   24:	7c 63 01 94 	addze   r3,r3
>   28:	4e 80 00 20 	blr
> 

Does that work when placed in a loop to?
Something close to the example in the first comment:

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 */

  parent reply	other threads:[~2021-06-03  7:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
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
2010-04-26 13:33 [Bug rtl-optimization/43892] New: " gcc-bugzilla at gcc dot gnu dot org
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-43892-4-TGNuWWkuie@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).