public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Daniel Berlin" <dberlin@dberlin.org>
To: "GCC Patches" <gcc-patches@gcc.gnu.org>
Subject: [PATCH]: Fix missed PRE optimization discovered
Date: Thu, 16 Oct 2008 23:29:00 -0000	[thread overview]
Message-ID: <4aca3dc20810161526r14037c7dq28f8fb2b4c7a679c@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

The attached fixes a missed optimization in PRE noticed by richard guenther.

We weren't caching phi translation results if they were constants,
which would cause us to fail to optimize things like:


int main(int argc)
{
int i;

if (argc)
  i = 5;
else
  i = 9;
 y = __builtin_pow(i, i);
 return y;
}

the result of phi translation would end up being constant, and we
would throw it away, which would cause us to assume phi translation
had failed.
Fixed by also adding constants to the phi translation table.
This is a regression from 4.3 for some cases, so i am committing it to mainline.

Bootstrapped and regtested on i686-darwin, committed.
2008-10-16  Daniel Berlin  <dberlin@dberlin.org>

	* tree-ssa-pre.c (phi_translate_set): Add constants to phi
	translation cache.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: premissed.diff --]
[-- Type: text/x-patch; name=premissed.diff, Size: 645 bytes --]

diff -r 2b8e288bbb69 gcc/tree-ssa-pre.c
--- a/gcc/tree-ssa-pre.c	Wed Oct 15 16:48:13 2008 +0000
+++ b/gcc/tree-ssa-pre.c	Thu Oct 16 18:22:34 2008 -0400
@@ -1745,9 +1745,8 @@
       pre_expr translated;
       translated = phi_translate (expr, set, NULL, pred, phiblock);
 
-      /* Don't add constants or empty translations to the cache, since
-	 we won't look them up that way, or use the result, anyway.  */
-      if (translated && !value_id_constant_p (get_expr_value_id (translated)))
+      /* Don't add empty translations to the cache  */
+      if (translated)
 	phi_trans_add (expr, translated, pred);
 
       if (translated != NULL)

             reply	other threads:[~2008-10-16 22:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-16 23:29 Daniel Berlin [this message]
2008-10-17 13:05 ` Andreas Schwab
2008-10-17 13:08   ` Eric Botcazou
2008-10-17 15:41     ` Daniel Berlin
2008-10-17 17:08       ` Daniel Berlin
2008-10-17 17:56         ` Daniel Berlin
2008-10-17 19:08         ` Eric Botcazou
2008-10-17 22:24           ` Daniel Berlin
2008-10-17 22:46           ` Laurent GUERBY
2008-10-18 10:28             ` Daniel Berlin
2008-10-18 18:03               ` Richard Guenther
2008-10-18 18:05                 ` Richard Guenther
2008-10-18 23:04                 ` Daniel Berlin
2008-10-19  4:23                   ` Richard Guenther
2008-10-20 20:23                     ` Daniel Berlin
2008-10-21 12:36                       ` Laurent GUERBY
2008-10-21 13:56                         ` Eric Botcazou
2008-10-21 14:08                           ` Laurent GUERBY
2008-10-21 14:23                             ` Andreas Schwab
2008-10-21 14:45                               ` Laurent GUERBY
2008-10-21 15:01                                 ` Andreas Schwab
2008-10-22 13:57                                   ` Laurent GUERBY
2008-10-22 14:04                                     ` Andreas Schwab
2008-10-22 14:40                                       ` Laurent GUERBY
2008-10-25 23:21                                       ` Ada ACATS random FAIL / scripting help wanted (was:Fix missed PRE optimization discovered) Laurent GUERBY
2008-10-26  0:17                                         ` Andreas Schwab
2008-10-26  0:33                                           ` Laurent GUERBY
2008-11-06 13:36                                             ` Laurent GUERBY
2008-11-06 14:03                                               ` Laurent GUERBY

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=4aca3dc20810161526r14037c7dq28f8fb2b4c7a679c@mail.gmail.com \
    --to=dberlin@dberlin.org \
    --cc=gcc-patches@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).