From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14575 invoked by alias); 21 Jan 2015 20:42:27 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14501 invoked by uid 48); 21 Jan 2015 20:42:21 -0000 From: "law at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/64700] Sink common code through PHI Date: Wed, 21 Jan 2015 20:42:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: law at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg02266.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64700 --- Comment #2 from Jeffrey A. Law --- I had a code hoisting pass on top of PRE a while back as well. Can't remember why I abandoned it. Oh yea, on top of PRE :-) I've still got a global code motion pass here based on Click's work. It handles both hoisting and sinking. Basically you record the earliest possible block for each statement and a latest block for each statement. The path through the dominator tree connecting those two blocks is the set of valid blocks for the statement. Then you just choose the 'best' one in that path. Most control dependent path within the shallowest loop nest. It didn't handle sinking PHIs or hoisting/sinking through a dependent node. Not sure if it could be changed to do that. I never pushed on it simply because it never did significantly better than the other code motion code we already have. It pointed out a few minor issues in tree-ssa-sink.c, but nothing that couldn't be easily fixed. Too bad, I always found the basic algorithm to be rather elegant. I'm certain we're missing all kinds of interesting code motions..