From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20479 invoked by alias); 23 Jan 2012 13:44:31 -0000 Received: (qmail 20465 invoked by uid 22791); 23 Jan 2012 13:44:29 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 13:44:16 +0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/51964] Missed tail merging opportunity Date: Mon, 23 Jan 2012 13:51: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-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-01/txt/msg02632.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51964 --- Comment #1 from vries at gcc dot gnu.org 2012-01-23 13:43:33 UTC --- I have a still rather vague idea that we might value number the uses rather than the defs: assign the same number to uses which use a value in the same way. I don't know how that would work exactly, but the idea is something like this: ... syntax: a -> b : a is used to copy to b a -> : a is used as b to define c and d. # .MEMD.1719_7 = PHI <.MEMD.1719_10(5), .MEMD.1719_11(6)> .MEMD.1719_10(5) -> .MEMD.1719_7 .MEMD.1719_11(6) -> .MEMD.1719_7 # aD.1712_1 = PHI aD.1712_4(5) -> aD.1712_1 aD.1712_5(6) -> aD.1712_1 # .MEMD.1719_10 = VDEF <.MEMD.1719_6> # USE = nonlocal # CLB = nonlocal aD.1712_4 = barD.1703 (7); bar -> .MEMD.1719_6 -> 7 -> # .MEMD.1719_11 = VDEF <.MEMD.1719_8(D)> # USE = nonlocal # CLB = nonlocal aD.1712_5 = barD.1703 (7); bar -> .MEMD.1719_8(D) -> 7 -> ... By comparing the value numbers of the uses of the 2 calls, we can conclude that the calls use values in the same way, which means we can merge them. And in order to merge them we need to insert phis to merge the actual values that are used. In the example above, we would only need a phi for .MEMD.1719_6 and .MEMD.1719_8(D). And if we had f.i. 'bar (7)' and 'bar (8)' in the example, this still would compare equal, and we would have to insert a phi (7,8) and use that as argument of the tail-merged call to bar.