From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17010 invoked by alias); 20 Nov 2009 09:24:35 -0000 Received: (qmail 16994 invoked by uid 22791); 20 Nov 2009 09:24:32 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,SUBJECT_FUZZY_VPILL 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, 20 Nov 2009 09:23:39 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAK9NZlN002602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Nov 2009 04:23:35 -0500 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAK9NWxL030630 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 20 Nov 2009 04:23:34 -0500 Received: from livre.localdomain (livre.oliva.athome.lsd.ic.unicamp.br [172.31.160.2]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.3/8.14.3) with ESMTP id nAK9NW2f022317; Fri, 20 Nov 2009 07:23:32 -0200 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5) with ESMTP id nAK9NVDE004078; Fri, 20 Nov 2009 07:23:31 -0200 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id nAK9NUcN004076; Fri, 20 Nov 2009 07:23:30 -0200 From: Alexandre Oliva To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: Re: [vta, graphite?] propagate degenerate phi nodes into debug stmts References: <84fc9c000911080156iff6d687o26db10af3e9fba5d@mail.gmail.com> <84fc9c000911170739v76a2e911vc6794e597c8d134e@mail.gmail.com> <84fc9c000911190255q12e2a1c8nc0af0587883d7455@mail.gmail.com> Date: Fri, 20 Nov 2009 09:26:00 -0000 In-Reply-To: <84fc9c000911190255q12e2a1c8nc0af0587883d7455@mail.gmail.com> (Richard Guenther's message of "Thu, 19 Nov 2009 11:55:22 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2009-11/txt/msg01081.txt.bz2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 1061 On Nov 19, 2009, Richard Guenther wrote: > On Thu, Nov 19, 2009 at 5:27 AM, Alexandre Oliva wrot= e: >> On Nov 17, 2009, Richard Guenther wrote: >>=20 >>> Well, just adjust degenerate_phi_result to do instead of calling >>> operand_equal_p >>=20 >>> =C2=A0 else if (TREE_CODE (arg) !=3D TREE_CODE (val) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|| (TREE_CODE (arg) =3D= =3D SSA_NAME >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& arg != =3D val) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|| !operand_equal_p (ar= g, val, 0)) >>> =C2=A0 =C2=A0 break; >>=20 >>> that should fix it. >>=20 >> Good idea. >> Here's what I'm testing now. > Ok if it passes testing. Thanks, but arg could be NULL, and then TREE_CODE (val) would crash. The fixed patch below corrects the two regressions I got testing the patch on x86_64-linux-gnu. Save for new regressions, I'll check in the revised version as soon as my current round of testing completes. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vta-ssa-dom-prop-degenerate.patch Content-length: 2681 for gcc/ChangeLog from Alexandre Oliva * tree-ssa.c (find_released_ssa_name): Handle NULL wi. (insert_debug_temp_for_var_def): Handle degenerate PHI nodes. (insert_debug_temps_for_defs): Handle PHI nodes. * tree-ssa-dom.c (degenerate_phi_result): Don't crash on released SSA names. Index: gcc/tree-ssa.c =================================================================== --- gcc/tree-ssa.c.orig 2009-11-19 05:12:30.000000000 -0200 +++ gcc/tree-ssa.c 2009-11-19 05:12:35.000000000 -0200 @@ -279,7 +279,7 @@ find_released_ssa_name (tree *tp, int *w { struct walk_stmt_info *wi = (struct walk_stmt_info *) data_; - if (wi->is_lhs) + if (wi && wi->is_lhs) return NULL_TREE; if (TREE_CODE (*tp) == SSA_NAME) @@ -346,7 +346,13 @@ insert_debug_temp_for_var_def (gimple_st /* If we didn't get an insertion point, and the stmt has already been removed, we won't be able to insert the debug bind stmt, so we'll have to drop debug information. */ - if (is_gimple_assign (def_stmt)) + if (gimple_code (def_stmt) == GIMPLE_PHI) + { + value = degenerate_phi_result (def_stmt); + if (value && walk_tree (&value, find_released_ssa_name, NULL, NULL)) + value = NULL; + } + else if (is_gimple_assign (def_stmt)) { bool no_value = false; @@ -408,6 +414,7 @@ insert_debug_temp_for_var_def (gimple_st at the expense of duplication of expressions. */ if (CONSTANT_CLASS_P (value) + || gimple_code (def_stmt) == GIMPLE_PHI || (usecount == 1 && (!gimple_assign_single_p (def_stmt) || is_gimple_min_invariant (value))) @@ -478,7 +485,7 @@ insert_debug_temps_for_defs (gimple_stmt stmt = gsi_stmt (*gsi); - FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, op_iter, SSA_OP_DEF) + FOR_EACH_PHI_OR_STMT_DEF (def_p, stmt, op_iter, SSA_OP_DEF) { tree var = DEF_FROM_PTR (def_p); Index: gcc/tree-ssa-dom.c =================================================================== --- gcc/tree-ssa-dom.c.orig 2009-11-19 05:12:30.000000000 -0200 +++ gcc/tree-ssa-dom.c 2009-11-20 04:30:10.000000000 -0200 @@ -2398,7 +2398,14 @@ degenerate_phi_result (gimple phi) continue; else if (!val) val = arg; - else if (!operand_equal_p (arg, val, 0)) + else if (arg == val) + continue; + /* We bring in some of operand_equal_p not only to speed things + up, but also to avoid crashing when dereferencing the type of + a released SSA name. */ + else if (!arg || TREE_CODE (val) != TREE_CODE (arg) + || TREE_CODE (val) == SSA_NAME + || !operand_equal_p (arg, val, 0)) break; } return (i == gimple_phi_num_args (phi) ? val : NULL); --=-=-= Content-length: 257 -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer --=-=-=--