From patchwork Fri Jun 10 12:17:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 99887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A5E40B7015 for ; Fri, 10 Jun 2011 22:18:12 +1000 (EST) Received: (qmail 8850 invoked by alias); 10 Jun 2011 12:18:10 -0000 Received: (qmail 8837 invoked by uid 22791); 10 Jun 2011 12:18:09 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL, BAYES_00, TW_HF, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Jun 2011 12:17:55 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 583CA5FC9F for ; Fri, 10 Jun 2011 14:17:54 +0200 (CEST) Date: Fri, 10 Jun 2011 14:17:54 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR49361 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 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);