From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29924 invoked by alias); 30 Dec 2002 18:20:42 -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 29894 invoked from network); 30 Dec 2002 18:20:41 -0000 Received: from unknown (HELO tone.orchestra.cse.unsw.EDU.AU) (129.94.242.28) by 209.249.29.67 with SMTP; 30 Dec 2002 18:20:41 -0000 Received: From cse.unsw.edu.au ([129.94.241.37] == ppp2-037.ppp2.cse.unsw.EDU.AU) (for ) By tone With Smtp ; Tue, 31 Dec 2002 05:20:28 +1100 From: Qiong Cai To: gcc@gcc.gnu.org Date: Mon, 30 Dec 2002 12:26:00 -0000 Message-ID: <3E112934.8060803@cse.unsw.edu.au> Reply-To: qiongc@cse.unsw.edu.au Organization: CSE, UNSW User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 Subject: gcse fails in this simple case Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-12/txt/msg01590.txt.bz2 Hi, I have the follwing code to test the implemenation of GCSE optimization in GCC. 0: int a, b; 1: 2: int fun(int ii, int jj) 3: { 4: int sum1, sum2; 5: sum1 = sum2 = 0; 6: 7: if ( ii > jj ) 8: sum1 = a + b; 9: else 10: sum2 = a + b; 11: 12: return sum1+sum2; 13: } However, GCC cannot find the common subexpression at Line 8 and 10. From the *.gcse debug dump, I found GCC consider the expression a+b as two different expressions at RTL level. The following RTL codes are from *.gcse dump: insn 22 57 24 (set (reg:SI 63) (mem/f:SI (symbol_ref:SI ("a")) [2 a+0 S4 A32])) 45 {*movsi_1} ... (insn 24 22 26 (set (reg:SI 64) (mem/f:SI (symbol_ref:SI ("b")) [2 b+0 S4 A32])) 45 {*movsi_1} ... (insn 26 24 27 (parallel[ <= a+b at Line 8 (set (reg/v:SI 61) (plus:SI (reg:SI 63) (reg:SI 64))) (clobber (reg:CC 17 flags)) ] ) 207 {*addsi_1} (nil) (nil)) ... (insn 32 58 34 (set (reg:SI 65) (mem/f:SI (symbol_ref:SI ("a")) [2 a+0 S4 A32])) 45 {*movsi_1} ... (insn 34 32 36 (set (reg:SI 66) (mem/f:SI (symbol_ref:SI ("b")) [2 b+0 S4 A32])) 45 {*movsi_1} .... (insn 36 34 37 (parallel[ <= a + b at Line 10 (set (reg/v:SI 62) (plus:SI (reg:SI 65) (reg:SI 66))) (clobber (reg:CC 17 flags)) ] ) 207 {*addsi_1} (nil) (nil)) From the above codes, we see gcse fails to eliminate the common loads of "a" and "b", and then fails to eliminate "a+b". I think it is a bug, or I miss something. My GCC compiler: > gcc -v > Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs > Configured with: ../gcc/configure --disable-libgcj > Thread model: posix > gcc version 3.2 Qiong