public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "acsawdey at linux dot vnet.ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/65391] unnecessary load of conditionally updated pointer in loop
Date: Wed, 11 Mar 2015 17:13:00 -0000	[thread overview]
Message-ID: <bug-65391-4-0zjOGek8qS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65391-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Aaron Sawdey <acsawdey at linux dot vnet.ibm.com> ---
Asm for the test case as in the description (load/store of *o_ptr for every
update):

compute_object_gain:
        ld 9,0(3)
        li 10,0
        std 10,0(4)
        cmpdi 7,9,0
        beqlr 7
        .p2align 5,,31
.L6:
        cmpd 7,5,9
        blt 7,.L3
        ld 10,0(4)
        add 9,10,9
        std 9,0(4)
.L3:
        ldu 9,8(3)
        cmpdi 7,9,0
        bne 7,.L6
        blr

Same test case, but with __restrict__ removed (essentially no difference):
compute_object_gain:
        li 9,0
        std 9,0(4)
        ld 9,0(3)
        cmpdi 7,9,0
        beqlr 7
        .p2align 5,,31
.L6:
        cmpd 7,5,9
        blt 7,.L3
        ld 10,0(4)
        add 9,10,9
        std 9,0(4)
.L3:
        ldu 9,8(3)
        cmpdi 7,9,0
        bne 7,.L6
        blr

Remove the if() and add __restrict__ back (no load or store of *o_ptr in the
loop):
compute_object_gain:
        ld 9,0(3)
        li 8,0
        li 10,0
        std 8,0(4)
        cmpdi 7,9,0
        beqlr 7
        .p2align 4,,15
.L5:
        add 10,10,9
        ldu 9,8(3)
        cmpdi 7,9,0
        bne 7,.L5
        std 10,0(4)
        blr

Remove both the if() and __restrict__ (now store to *o_ptr is in the loop but
no load):
compute_object_gain:
        li 9,0
        li 10,0
        std 9,0(4)
        ld 9,0(3)
        cmpdi 7,9,0
        beqlr 7
        .p2align 5,,31
.L5:
        add 10,10,9
        std 10,0(4)
        ldu 9,8(3)
        cmpdi 7,9,0
        bne 7,.L5
        blr


  parent reply	other threads:[~2015-03-11 17:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11 16:12 [Bug middle-end/65391] New: " acsawdey at linux dot vnet.ibm.com
2015-03-11 16:49 ` [Bug middle-end/65391] " dje at gcc dot gnu.org
2015-03-11 17:13 ` acsawdey at linux dot vnet.ibm.com [this message]
2015-03-11 19:19 ` acsawdey at linux dot vnet.ibm.com
2015-03-12 11:11 ` [Bug tree-optimization/65391] missed store motion for " rguenth 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-65391-4-0zjOGek8qS@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).