public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/43491] Unnecessary temporary for global register variable
Date: Thu, 16 Feb 2012 14:55:00 -0000	[thread overview]
Message-ID: <bug-43491-4-Wji8KDyCq4@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 #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-16 14:43:51 UTC ---
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.


  parent reply	other threads:[~2012-02-16 14:49 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 [this message]
2012-02-17  4:48 ` amker.cheng at gmail dot com
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-Wji8KDyCq4@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).