From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15942 invoked by alias); 7 Nov 2011 16:08:34 -0000 Received: (qmail 15932 invoked by uid 22791); 7 Nov 2011 16:08:33 -0000 X-SWARE-Spam-Status: No, hits=-7.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS 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; Mon, 07 Nov 2011 16:07:59 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA7G7w4F021704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Nov 2011 11:07:58 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pA7G7v0N015969; Mon, 7 Nov 2011 11:07:58 -0500 Received: from [10.3.113.8] ([10.3.113.8]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pA7G7tYi016544; Mon, 7 Nov 2011 11:07:56 -0500 Message-ID: <4EB8025B.8030102@redhat.com> Date: Mon, 07 Nov 2011 16:14:00 -0000 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0 MIME-Version: 1.0 To: Richard Guenther CC: Jakub Jelinek , gcc-patches Subject: Re: RFA: New pass to delete unexecutable paths in the CFG References: <4EB7AAF6.6060702@redhat.com> <20111107100700.GH27375@tyan-ft48-01.lab.bos.redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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: 2011-11/txt/msg00978.txt.bz2 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > > I also wonder if instead of a new pass control-dependent DCE can be > taught of this? It could. I'm not sure it really buys us anything except maybe being able to reuse the pdom & control-dependency analysis. It actually more naturally belongs in cprop because it's cprop that exposes NULL pointers in useful ways (in memory dereferences and as PHI args). At least I presume that this code removal can > expose DCE opportunities and DCE can expose these code removal > opportunities? In theory, yes. However, because we find & remove the edge upon which the memory reference is control dependent upon, what we really expose is unreachable code. Hence the CFG cleanup pass. Secondary effects I've witnessed are more block merging exposed due to CFG simplifications and further const/copy propagation exposed by edge removal at the point where unexecutable & executable paths meet. It's not hard to imagine how this could lead to additional DCE opportunities and other optimizations, I just haven't looked for them or noticed them. The valgrind results are a good indication that we're picking up good secondary optimizations. I don't think DCE will often lead to new opportunities for this code, it could happen, but I'd expect it to be the exception rather than the norm. FWIW, the location of the pass right now sits just after DOM1 so a goodly amount of constant propagation is already done, but we still get a chance to pick up the secondary optimization opportunities in DOM2. The pass also sits between two DCE passes, so if DCE is exposing opportunities for this pass, we get them and if this pass is exposing opportunities for DCE, we get them too :-) > > Did you consider simplifying the code by simply relying on > points-to analysis? Thus for the dereferenced SSA name check > > pi = SSA_NAME_PTR_INFO (name); if (pi && pt_solution_empty_p > (&pi->pt)) Nope. I guess it could be added, though it's often important to know the origin of the NULL pointer. p5 = PHI (p4 (1), 0 (0)) ... if (cond) goto X else goto Y X: foo (P5) goto Z Y: *p5 = Z: Analysis will mark P5 is being potentially NULL, but it would incorrect to remove the edge corresponding to the NULL PHI arguement as traversing that edge does not guarantee we will dereference the NULL pointer. The most interesting answer from PTA would be things like this pointer must be NULL, but if that's true, then it should have been propagated to the use sites already. > ... > > ? I once implemented a warning to warn about such derefrences, but > it (of course ...) triggers for all the unexecutable code paths... Yup. The one I've got here looks like a traditional propagation engine. There's knobs on it to tweak how it handles loads from memory, call return values, etc. Utilizing PTA would certainly help. I'll put that on the TODO list. I would have liked to have it polished in time for GCC 4.7, but other events got in the way. Jeff -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJOuAJbAAoJEBRtltQi2kC7cA4H/jrPusXwvf0ECDh5MP/hNcna R+zHWQPVOsPsyZkJCEuGqBkLT0+2ar0fS0uiqcXrZelY+TqAw0geg5t60w4lHF9p 9ERDqsBExVZW0X2VdnTZrYyfyB/fOc9xIizp/KxDWV33i7CwDFOyYR7QwXZnAMcp 7lpdzzxRbFaq05kj9K2aFtt8X/N7+Gn7dsI7kTLexmU2T+rXEF8P/HEqNefz70tV t23W9V81cbZDP9g9LhJzrMfQrylI/lSk+Nve10aBal0EVPi5IzWAvxfL5uxD3G4l sxOuH9bD7dNGDdJI1JnFxz56Z4DNI/0ARHM/RsZDbcAFUm8FG/DIzitBPslFegY= =24NO -----END PGP SIGNATURE-----