public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luoxhu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/61837] missed loop invariant expression optimization
Date: Tue, 07 Apr 2020 07:30:58 +0000	[thread overview]
Message-ID: <bug-61837-4-ahR3brQ4QZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61837-4@http.gcc.gnu.org/bugzilla/>

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

luoxhu at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |luoxhu at gcc dot gnu.org

--- Comment #3 from luoxhu at gcc dot gnu.org ---
"addi 8,4,-1" and "subf 9,8,5" could not be hoisted out as there are dependency
to "lbzu 9,1(8)". r8 need be initialized to p2-1 in each iteration of outer
loop. Only the result of subf 9,8,5 is loop invariant (p2+s-1)-(p2-1).

But the latest GCC code could be optimized as A, B, C is loop invariant.

foo:
.LFB0:
        .cfi_startproc
        cmpwi 7,5,0
        li 6,0
        rldicl 5,5,0,32
        li 7,0
        .p2align 4,,15
.L2:
        ble 7,.L7
        addi 8,5,-1       // A
        addi 10,4,-1
        rldicl 8,8,0,32   // B
        mr 9,3
        addi 8,8,1        // C
        mtctr 8
        .p2align 5
.L4:
        lbzu 8,1(10)
        cmpw 0,8,7
        bne 0,.L3
        stw 6,0(9)
.L3:
        addi 9,9,4
        bdnz .L4
.L7:
        addi 6,6,88
        addi 7,7,1
        cmpwi 0,6,8888
        extsw 7,7
        extsw 6,6
        bne 0,.L2
        blr

       reply	other threads:[~2020-04-07  7:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-61837-4@http.gcc.gnu.org/bugzilla/>
2020-04-07  7:30 ` luoxhu at gcc dot gnu.org [this message]
2020-04-07 16:37 ` segher at gcc dot gnu.org
2020-04-13 10:31 ` luoxhu at gcc dot gnu.org
2020-04-14  6:42 ` segher at gcc dot gnu.org
2020-04-14  7:01 ` luoxhu at gcc dot gnu.org
2020-04-14  7:26 ` segher at gcc dot gnu.org
2020-04-14  7:52 ` luoxhu at gcc dot gnu.org
2020-04-14 10:37 ` rguenth at gcc dot gnu.org
2020-05-15  3:27 ` cvs-commit at gcc dot gnu.org
2021-07-29  0:43 ` cvs-commit at gcc dot gnu.org
2021-08-12  2:17 ` guojiufu at gcc dot gnu.org

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-61837-4-ahR3brQ4QZ@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).