From patchwork Fri Jun 3 14:28:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 98588 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 735EBB6FA8 for ; Sat, 4 Jun 2011 00:33:28 +1000 (EST) Received: (qmail 17176 invoked by alias); 3 Jun 2011 14:33:27 -0000 Received: (qmail 17162 invoked by uid 22791); 3 Jun 2011 14:33:24 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Jun 2011 14:33:06 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p53EX5Bj012249 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Jun 2011 10:33:06 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p53EWwGO019684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 3 Jun 2011 10:33:05 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id p53EWsq6021824; Fri, 3 Jun 2011 11:32:55 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p53EStDF021207; Fri, 3 Jun 2011 11:28:55 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id p53ESsxb021205; Fri, 3 Jun 2011 11:28:54 -0300 From: Alexandre Oliva To: Richard Guenther Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix ICE in expand_cse_reciprocals (PR tree-optimization/42078) References: <20091118173010.GL3047@sunsite.ms.mff.cuni.cz> <84fc9c000911190615v65576f2ahd76a0f28b3f725ae@mail.gmail.com> Date: Fri, 03 Jun 2011 11:28:53 -0300 In-Reply-To: (Alexandre Oliva's message of "Fri, 20 Nov 2009 07:36:00 -0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) 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 According to http://gcc.gnu.org/ml/gcc-patches/2009-11/msg01082.html on Nov 20, 2009, Alexandre Oliva wrote: > On Nov 19, 2009, Richard Guenther wrote: >> In fact this exchanging of the LHS (or rather invalidating of the >> SSA name value) should be a helper function that knows >> the implementation details and avoids going through releasing >> and allocating the name. > Okie dokie, here's a sequence of patches that implements helper > functions for this sort of stuff. > The first patch introduces machinery to propagate “dying” DEFs into > debug stmts, while replacing them with other SSA_NAMEs. This is already in. > The second extends it so as to enable the old LHS to be redefined > e.g. in terms of the new LHS. IIRC this may be useful in some other > transformations that, in the process of introducing VTA, I changed from > modifying stmts in place to inserting new stmts and removing others. I > haven't looked for them yet. > The third uses this new feature for the case at hand, while avoiding > computing the reciprocal expression if we know it won't be used. Updated versions of these follow. Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? for gcc/ChangeLog from Alexandre Oliva PR tree-optimization/42078 * tree-ssa-math-opts.c (execute_cse_reciprocals): Compute reciprocal value for debug stmts. Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c.orig 2011-06-03 01:29:09.427075107 -0300 +++ gcc/tree-ssa-math-opts.c 2011-06-03 01:30:25.688009048 -0300 @@ -574,6 +574,7 @@ execute_cse_reciprocals (void) bool md_code, fail; imm_use_iterator ui; use_operand_p use_p; + tree value; code = DECL_FUNCTION_CODE (fndecl); md_code = DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD; @@ -603,13 +604,24 @@ execute_cse_reciprocals (void) if (fail) continue; - gimple_replace_lhs (stmt1, arg1, NULL); + if (gimple_replace_lhs_wants_value ()) + { + tree t = TREE_TYPE (arg1); + + value = build2 (RDIV_EXPR, t, build_one_cst (t), arg1); + } + else + value = NULL; + + gimple_replace_lhs (stmt1, arg1, value); gimple_call_set_fndecl (stmt1, fndecl); update_stmt (stmt1); reciprocal_stats.rfuncs_inserted++; FOR_EACH_IMM_USE_STMT (stmt, ui, arg1) { + if (is_gimple_debug (stmt)) + continue; gimple_assign_set_rhs_code (stmt, MULT_EXPR); fold_stmt_inplace (stmt); update_stmt (stmt);