From patchwork Mon Mar 25 19:08:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 230977 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 89B482C00C2 for ; Tue, 26 Mar 2013 06:08:39 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=u/t1g4BT0kBSuO41s Kkmbvj3jLYvrv67QlrhLZ/Fjm1q+HoGni8OM54C+RhDE/rxRsKSIZVibNMw1oTh1 DQ+uVOCSt5JZUrNy/SDRsWR0ZEln/ODEXF8uNrY/rIVfvBXy0Mk5hhKo2EjsEmfk hY76KrNuNtvlWpt2mQGrkfrUdc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=F3edQ/KvU2LjQfxzocHFNiN 8XDc=; b=RVyLSPGCSKBdVgXEKNDuBgNfHTKjpBSXHWeOnB/WsWDRlnajgxOXN+q hM/uR+Dbz0GFwITEY3KdllbdcTXq9jzKi3L5fzb+X1pzp3Qqs0U2zFusuoCDim8m HcSVdR6jNQPvTFd7ZpNoM4GyyGSULkPnHzeI5hQnyDpCj0OTsYds= Received: (qmail 17849 invoked by alias); 25 Mar 2013 19:08:27 -0000 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 Received: (qmail 17817 invoked by uid 89); 25 Mar 2013 19:08:20 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 25 Mar 2013 19:08:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2PJ8IF9020881 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Mar 2013 15:08:19 -0400 Received: from stumpy.slc.redhat.com (ovpn-113-48.phx2.redhat.com [10.3.113.48]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2PJ8IE2010260; Mon, 25 Mar 2013 15:08:18 -0400 Message-ID: <5150A0A2.5020400@redhat.com> Date: Mon, 25 Mar 2013 13:08:18 -0600 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Richard Biener CC: gcc-patches Subject: Re: Record missing equivalence References: <514A8FE6.7060704@redhat.com> In-Reply-To: X-Virus-Found: No On 03/21/2013 03:44 AM, Richard Biener wrote: >> + /* If LHS is an SSA_NAME and RHS is a constant and LHS was set >> + via a widening type conversion, then we may be able to record >> + additional equivalences. */ >> + if (lhs >> + && TREE_CODE (lhs) == SSA_NAME >> + && is_gimple_constant (rhs)) >> + { >> + gimple defstmt = SSA_NAME_DEF_STMT (lhs); >> + >> + if (defstmt >> + && is_gimple_assign (defstmt) >> + && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (defstmt))) >> + { >> + tree old_rhs = gimple_assign_rhs1 (defstmt); >> + tree newval = fold_convert (TREE_TYPE (old_rhs), rhs); > > You want to delay that folding and creating of a new tree node until after ... > >> + >> + /* If this was a widening conversion and if RHS is >> converted >> + to the type of OLD_RHS and has the same value, then we >> + can record an equivalence between OLD_RHS and the >> + converted representation of RHS. */ >> + if ((TYPE_PRECISION (TREE_TYPE (lhs)) >> + > TYPE_PRECISION (TREE_TYPE (old_rhs))) > > ... this check. > >> + && operand_equal_p (rhs, newval, 0)) > > If you'd restricted yourself to handling INTEGER_CSTs then using > int_fits_type_p (rhs, TREE_TYPE (lhs)) would have been enough to check. > > And operand_equal_p will never return for non-equal typed non-INTEGER_CSTs > anyway ... Agreed. Addressed via the attached patch which was committed after a bootstrap and regression test on x86_64-unknown-linux-gnu. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9bdf1e5..9db0629 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-03-25 Jeff Law + + * tree-ssa-dom.c (record_equivalences_from_incoming_edge): Rework + slightly to avoid creating and folding useless trees. Simplify + slightly by restricting to INTEGER_CSTs and using int_fits_type_p. + 2013-03-25 Uros Bizjak * config/i386/i386.md (*zero_extendsidi2): Merge with diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 57b814c..a71c6dc 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1135,12 +1135,13 @@ record_equivalences_from_incoming_edge (basic_block bb) if (lhs) record_equality (lhs, rhs); - /* If LHS is an SSA_NAME and RHS is a constant and LHS was set - via a widening type conversion, then we may be able to record + /* If LHS is an SSA_NAME and RHS is a constant integer and LHS was + set via a widening type conversion, then we may be able to record additional equivalences. */ if (lhs && TREE_CODE (lhs) == SSA_NAME - && is_gimple_constant (rhs)) + && is_gimple_constant (rhs) + && TREE_CODE (rhs) == INTEGER_CST) { gimple defstmt = SSA_NAME_DEF_STMT (lhs); @@ -1149,16 +1150,14 @@ record_equivalences_from_incoming_edge (basic_block bb) && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (defstmt))) { tree old_rhs = gimple_assign_rhs1 (defstmt); - tree newval = fold_convert (TREE_TYPE (old_rhs), rhs); - - /* If this was a widening conversion and if RHS is converted - to the type of OLD_RHS and has the same value, then we - can record an equivalence between OLD_RHS and the - converted representation of RHS. */ - if ((TYPE_PRECISION (TREE_TYPE (lhs)) - > TYPE_PRECISION (TREE_TYPE (old_rhs))) - && operand_equal_p (rhs, newval, 0)) - record_equality (old_rhs, newval); + + /* If the constant is in the range of the type of OLD_RHS, + then convert the constant and record the equivalence. */ + if (int_fits_type_p (rhs, TREE_TYPE (old_rhs))) + { + tree newval = fold_convert (TREE_TYPE (old_rhs), rhs); + record_equality (old_rhs, newval); + } } }