public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amker.cheng at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/43491] Unnecessary temporary for global register variable
Date: Fri, 17 Feb 2012 04:48:00 -0000	[thread overview]
Message-ID: <bug-43491-4-IV6ZS5XW6V@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-43491-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from amker.cheng <amker.cheng at gmail dot com> 2012-02-17 03:55:24 UTC ---
(In reply to comment #7)
> With tree hoisting we generate
> 
> <bb 2>:
>   pretmp.5_19 = data_0;
>   pretmp.5_20 = data_3;
>   i_21 = pretmp.5_19 + pretmp.5_20;
>   if (data_3(D) != 0)
>     goto <bb 3>;
>   else
>     goto <bb 4>;
> 
> <bb 3>:
> 
> <bb 4>:
>   # v_1 = PHI <v_7(D)(3), 2(2)>
>   # i_2 = PHI <i_21(3), 5(2)>
>   D.1719_14 = v_1 * i_21;
>   D.1718_15 = i_2 * D.1719_14;
>   return D.1718_15;
> 
> instead of
> 
> <bb 2>:
>   if (data_3(D) != 0)
>     goto <bb 4>;
>   else
>     goto <bb 3>;
> 
> <bb 3>:
>   pretmp.5_19 = data_0;
>   pretmp.5_21 = data_3;
>   i_23 = pretmp.5_19 + pretmp.5_21;
>   goto <bb 5>;
> 
> <bb 4>:
>   data_0.0_4 = data_0;
>   data_3.1_5 = data_3;
>   i_6 = data_0.0_4 + data_3.1_5;
> 
> <bb 5>:
>   # v_1 = PHI <v_7(D)(4), 2(3)>
>   # i_2 = PHI <i_6(4), 5(3)>
>   # i_24 = PHI <i_6(4), i_23(3)>
>   D.1719_14 = v_1 * i_24;
>   D.1718_15 = i_2 * D.1719_14;
>   return D.1718_15;
> 
> }
> 
> I suppose that's good enough?  See that PRE still inserts loads from
> register variables, not sure if you'd want to disallow that as well.

I think the reason why gcc inserts loads from global register variable is gcc
treats loads/uses of such variable as memory references. If I am right, It
seems a ssa issue, rather than PRE.
As for the original bug, it is caused by loading const global register
variable, then using the loaded ssa var across function calls(this step by
pre), which introduces unnecessary register conflict. I guess the load itself
won't hurt, but not sure whether hoisting will(as pre had done before).

BTW, I did not get the hoisted code on trunk. Is it a patch your are working
on?

Thanks.


  parent reply	other threads:[~2012-02-17  3:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-43491-4@http.gcc.gnu.org/bugzilla/>
2011-11-23  8:35 ` [Bug rtl-optimization/43491] " amker.cheng at gmail dot com
2011-11-24 10:22 ` amker.cheng at gmail dot com
2011-12-21  4:35 ` amker.cheng at gmail dot com
2011-12-21  8:11 ` [Bug tree-optimization/43491] " ubizjak at gmail dot com
2011-12-23  6:32 ` jye2 at gcc dot gnu.org
2012-02-16 14:55 ` rguenth at gcc dot gnu.org
2012-02-17  4:48 ` amker.cheng at gmail dot com [this message]
2014-05-09  9:48 ` 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-43491-4-IV6ZS5XW6V@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).