public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcse fails in this simple case
@ 2002-12-30 12:26 Qiong Cai
  0 siblings, 0 replies; only message in thread
From: Qiong Cai @ 2002-12-30 12:26 UTC (permalink / raw)
  To: gcc

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







^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-30 18:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-30 12:26 gcse fails in this simple case Qiong Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).