public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR49361
Date: Fri, 10 Jun 2011 13:03:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1106101416430.810@zhemvz.fhfr.qr> (raw)


This fixes a fallout of pow(x,2.0) expander removal.  As discussed
several times we shouldn't really fold x*x to pow(x,2) - at least
not when we're in gimple form already as we'll never see
followup folding opportunities that folding was designed to catch.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2011-06-10  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/49361
	* fold-const.c (fold_binary_loc): Only fold x * x to pow (x, 2.0)
	when not already in gimple form.

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 174891)
+++ gcc/fold-const.c	(working copy)
@@ -10519,7 +10519,8 @@ fold_binary_loc (location_t loc,
 		}
 
 	      /* Optimize x*x as pow(x,2.0), which is expanded as x*x.  */
-	      if (optimize_function_for_speed_p (cfun)
+	      if (!in_gimple_form
+		  && optimize_function_for_speed_p (cfun)
 		  && operand_equal_p (arg0, arg1, 0))
 		{
 		  tree powfn = mathfn_built_in (type, BUILT_IN_POW);

                 reply	other threads:[~2011-06-10 12:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=alpine.LNX.2.00.1106101416430.810@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --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).