public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "npiggin at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/102062] powerpc suboptimal unrolling simple array sum
Date: Wed, 25 Aug 2021 13:01:54 +0000	[thread overview]
Message-ID: <bug-102062-4-LZBTqIb38N@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102062-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Nicholas Piggin <npiggin at gmail dot com> ---
(In reply to Bill Schmidt from comment #2)
> As expected, I get similar code when compiling either for P9 or P10.

Oh I should have specified, -O2 is the only option. If I add
-fvariable-expansion-in-unroller it has no effect, just to make sure.

It's gcc from Debian (gcc version 11.2.0 (Debian 11.2.0-3)). Maybe they've done
something to change this.(In reply to Bill Schmidt from comment #1)
> Regarding the latter question, I'm surprised it's not being done.  This
> behavior is controlled by -fvariable-expansion-in-unroller, which was
> enabled by default for PowerPC targets a couple of releases back.  You
> reported this against GCC 11.2, but I'm skeptical.  What options are you
> using?
> 
> Compiling with -O2 and current trunk, I see variable expansion kicking in,
> and I also see the same base register in use in all references in the loop:
> 
> test:
> .LFB0:
>         .cfi_startproc
>         .localentry     test,1
>         slwi 4,4,1
>         li 10,0
>         li 7,0
>         addi 9,3,-4
>         extsw 4,4
>         andi. 6,4,0x3
>         addi 5,4,-1
>         mr 8,4
>         beq 0,.L9
>         cmpdi 0,6,1
>         beq 0,.L13
>         cmpdi 0,6,2
>         bne 0,.L22
> .L14:
>         lwzu 6,4(9)
>         addi 4,4,-1
>         add 10,10,6
> .L13:
>         lwzu 6,4(9)
>         cmpdi 0,4,1
>         add 10,10,6
>         beq 0,.L19
> .L9:
>         srdi 8,8,2
>         mtctr 8
> .L2:
>         lwz 4,4(9)
>         lwz 5,12(9)
>         lwz 6,8(9)
>         lwzu 8,16(9)
>         add 10,4,10
>         add 10,10,5
>         add 7,6,7
>         add 7,7,8
>         bdnz .L2
> .L19:
>         add 3,10,7
>         extsw 3,3
>         blr
>         .p2align 4,,15
> .L22:
>         lwz 10,0(3)
>         mr 9,3
>         mr 4,5
>         b .L14

That asm does well on the test, better than my version (a little bit on P9, a
lot on P10). It does have 2x more unrolling which probably helps a bit.

  parent reply	other threads:[~2021-08-25 13:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 11:27 [Bug c/102062] New: " npiggin at gmail dot com
2021-08-25 11:52 ` [Bug c/102062] " wschmidt at gcc dot gnu.org
2021-08-25 11:55 ` wschmidt at gcc dot gnu.org
2021-08-25 12:43 ` npiggin at gmail dot com
2021-08-25 12:50 ` wschmidt at gcc dot gnu.org
2021-08-25 13:01 ` npiggin at gmail dot com [this message]
2021-08-25 14:05 ` segher at gcc dot gnu.org
2021-08-25 14:10 ` segher at gcc dot gnu.org
2021-08-25 15:31 ` linkw at gcc dot gnu.org
2021-08-25 17:07 ` segher at gcc dot gnu.org
2021-08-25 18:01 ` wschmidt at gcc dot gnu.org
2021-08-25 18:03 ` dje at gcc dot gnu.org
2021-08-25 22:43 ` segher at gcc dot gnu.org
2021-08-25 23:29 ` [Bug rtl-optimization/102062] " dje at gcc dot gnu.org
2021-08-26  0:17 ` npiggin at gmail dot com
2021-08-30 17:34 ` segher at gcc dot gnu.org
2021-09-22 13:53 ` npiggin at gmail dot com

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-102062-4-LZBTqIb38N@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).