From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8790 invoked by alias); 2 May 2002 12:46:30 -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 8731 invoked from network); 2 May 2002 12:46:21 -0000 Received: from unknown (HELO swan.prod.itd.earthlink.net) (207.217.120.123) by sources.redhat.com with SMTP; 2 May 2002 12:46:21 -0000 Received: from dialup-63.214.71.216.dial1.boston1.level3.net ([63.214.71.216]) by swan.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 173FyN-0004ih-00; Thu, 02 May 2002 05:46:13 -0700 Mime-Version: 1.0 X-Sender: qsmgmt@pop.earthlink.net Message-Id: In-Reply-To: <000c01c1f1db$a589fc20$66d908d5@dlivshin> References: <001301c1f113$907bf540$91d808d5@dlivshin> <001301c1f1a4$0a0ae020$73d808d5@dlivshin> <20020501232220.A4494@redhat.com> <000c01c1f1db$a589fc20$66d908d5@dlivshin> Date: Thu, 02 May 2002 05:46:00 -0000 To: "David Livshin" From: Alan Lehotsky Subject: Re: gcc port to StarCore Cc: "Richard Henderson" , Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-SW-Source: 2002-05/txt/msg00135.txt.bz2 At 3:16 PM +0200 5/2/02, David Livshin wrote: >..... > >Are you saying that in order to benefit from constant propagation in the: > >x = 10; >y = 100; >if ( x > y ) >... > >'define_expand "cmpsi"' may not be used? Not to put words in Richard's mouth.....but..... What he's saying is that the DEFINE_EXPAND just produces the initial RTL, and as I mentioned earlier, the compiler will normally decide to load immediates to pseudos when it initially generates code. You HAVE to use the "cmpsi" pattern otherwise, you'd never generate any compare RTL (although I think it may be the case that the compiler can generate calls to the runtime library to do compares out-of-line) >Would you please direct me to a material ( source code and/or document ) >that may clarify the way this optimization is implemented by the GNU >compiler. Right now I even cant guess what it might be. For example I tried >in md: > >( define_insn "addsi3" > [ ( set > ( match_operand:SI 0 "register_operand" "" ) > ( plus:SI ( match_operand:SI 1 "general_operand" "" ) > ( match_operand:SI 2 "general_operand" "" ) > ) > ) > ] >.... Okay. This pattern is missing all constraints. (The characters inside the last "" on each match_operand) I'm not certain that would prevent constant folding (in fact I can't imagine how it could), but you should fix that before looking for other problems.... The other thing that occurs to me is whether you've defined the various COSTS macros (CONST_COSTS, ADDRESS_COST and RTX_COST). Also check your LEGITIMATE_CONSTANT_P macro is reasonable.... >and then compiled: > >x = 10; >y = 100; >z = x + y; >... > >It seems from the resulting code: > > moveu.l #10,d0 > move.l d0,_x > moveu.l #100,d2 > move.l d2,_y > add #10,d2,d2 > move.l d2,_z > >that compiler understands that 'x' is equal to 10 but misses the fact that >'y' is also a constant and 'z' is always equal to 110( or something inside >the compiler forces the generation of the add instruction ). Just in-case >you are wondering: description of "movsi" in my md file allows load of any >constant to any register. An RTL dump would be a good thing to see, just to insure that the RTL you generated isn't munged in some unpredictable fashion. >Thank you, > >David -- Quality Software Management http://home.earthlink.net/~qsmgmt apl@alum.mit.edu (978)287-0435 Voice (978)808-6836 Cell Software Process Improvement / Management Consulting Language Design / Compiler Implementation