From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16763 invoked by alias); 17 Feb 2012 03:56:00 -0000 Received: (qmail 16753 invoked by uid 22791); 17 Feb 2012 03:56:00 -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; Fri, 17 Feb 2012 03:55:47 +0000 From: "amker.cheng at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/43491] Unnecessary temporary for global register variable Date: Fri, 17 Feb 2012 04:48: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: missed-optimization, ra X-Bugzilla-Severity: enhancement X-Bugzilla-Who: amker.cheng at gmail 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-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-02/txt/msg01758.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491 --- Comment #8 from amker.cheng 2012-02-17 03:55:24 UTC --- (In reply to comment #7) > With tree hoisting we generate > > : > pretmp.5_19 = data_0; > pretmp.5_20 = data_3; > i_21 = pretmp.5_19 + pretmp.5_20; > if (data_3(D) != 0) > goto ; > else > goto ; > > : > > : > # v_1 = PHI > # i_2 = PHI > D.1719_14 = v_1 * i_21; > D.1718_15 = i_2 * D.1719_14; > return D.1718_15; > > instead of > > : > if (data_3(D) != 0) > goto ; > else > goto ; > > : > pretmp.5_19 = data_0; > pretmp.5_21 = data_3; > i_23 = pretmp.5_19 + pretmp.5_21; > goto ; > > : > data_0.0_4 = data_0; > data_3.1_5 = data_3; > i_6 = data_0.0_4 + data_3.1_5; > > : > # v_1 = PHI > # i_2 = PHI > # i_24 = PHI > D.1719_14 = v_1 * i_24; > D.1718_15 = i_2 * D.1719_14; > return D.1718_15; > > } > > I suppose that's good enough? See that PRE still inserts loads from > register variables, not sure if you'd want to disallow that as well. I think the reason why gcc inserts loads from global register variable is gcc treats loads/uses of such variable as memory references. If I am right, It seems a ssa issue, rather than PRE. As for the original bug, it is caused by loading const global register variable, then using the loaded ssa var across function calls(this step by pre), which introduces unnecessary register conflict. I guess the load itself won't hurt, but not sure whether hoisting will(as pre had done before). BTW, I did not get the hoisted code on trunk. Is it a patch your are working on? Thanks.