From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5377 invoked by alias); 15 Jan 2003 21:52:55 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 5364 invoked from network); 15 Jan 2003 21:52:53 -0000 Received: from unknown (HELO mail.kloo.net) (63.192.214.25) by sources.redhat.com with SMTP; 15 Jan 2003 21:52:53 -0000 Received: by mail.kloo.net (Postfix, from userid 504) id 076043B0318; Wed, 15 Jan 2003 13:47:15 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.kloo.net (Postfix) with ESMTP id 025003B4319; Wed, 15 Jan 2003 13:47:14 -0800 (PST) Date: Thu, 16 Jan 2003 11:03:00 -0000 From: To: Reza Roboubi Cc: Bonzini , gcc@gcc.gnu.org, gcc-help@gcc.gnu.org Subject: Re: optimizations In-Reply-To: <3E25C06E.4E7D37E8@linisoft.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-01/txt/msg00732.txt.bz2 On Wed, 15 Jan 2003, Reza Roboubi wrote: > Bonzini wrote: > > CHANGE: > ------- > .L2: > movl -4(%ebp), %eax <== still does the load > cmpl $16, %eax > je .L7 > incl %eax > movl %eax, -4(%ebp) <== and store > jmp .L2 > .L7: > > TO: > ------- > movl -4(%ebp), %eax > .L2: > cmpl $16, %eax > je .L7 > incl %eax > jmp .L2 > .L7: > movl %eax, -4(%ebp) The optimization you are suggesting is called "load hoist/store sink" if I remember correctly. Here is the story as I remember it: When egcs-1.0 or 1.1 was released, people noticed a large performance drop from gcc-2.7.2. I did a little investigation, and verified a large performanc drop on Whetstone. I did a comprehensive analysis of it, and isolated a case similar to yours where a variable in a critical loop was entirely contained in registers in 2.7.2 but was loaded/save from/to memory in gcc-2.95. I mentioned this on the gcc-bugs mailing list, and Mark Mitchell contributed a fairly simple load hoisting improvement to the loop optmiizer which restored performance on Whetstone. If you look at the gcc-bugs archives for 1998, you may be able to find this message thread. This load-hoisting optimization seems to be responsible for the hoisted load in your testcase. However, the corresponding store sink portion of the optimizer has never been written, and I believe that is why the store is not sunk out of the loop on your testcase. Toshi