This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SSA question


> OK.    So let's consider
> foo()
> {
>   int a,b,c;
>
>   a = b + c;
>   b = 5;
>   c = 9;
> }

BTW, here is the before and after on a similar testcase (changed to avoid
having values optimized away):

int bar();
int foo()
{
  int a,b,c;

  a = b + c;
  b = bar();
  c = bar();
  return a + b + c;
}

Before:

(insn 9 33 11 (set (reg/v:SI 107)
        (plus:SI (reg/v:SI 108)                ** Use of 108
            (reg/v:SI 109))) 47 {addsi3} (nil) ** Use of 109
    (nil))

(call_insn 11 9 13 (set (reg:SI 108)           ** Def of 108
        (call (mem:PDI (symbol_ref:PDI ("bar")) 0)
            (const_int 0 [0x0]))) -1 (nil)
    (nil)
    (nil))

(call_insn 15 13 17 (set (reg:SI 109)          ** Def of 109
        (call (mem:PDI (symbol_ref:PDI ("bar")) 0)
            (const_int 0 [0x0]))) -1 (nil)
    (nil)
    (nil))

(insn 21 17 22 (set (reg:SI 110)
        (plus:SI (reg/v:SI 107)
            (reg/v:SI 108))) 47 {addsi3} (nil)
    (nil))

(insn 22 21 24 (set (reg:SI 111)
        (plus:SI (reg:SI 110)
            (reg/v:SI 109))) 47 {addsi3} (nil)
    (nil))
...

After:

(insn 9 33 11 (set (reg/v:SI 107)
        (plus:SI (reg:SI 111)                     ** Use of 111
            (reg:SI 112))) 47 {addsi3} (nil)      ** Use of 112
    (nil))

(call_insn 11 9 13 (set (reg:SI 108)
        (call (mem:PDI (symbol_ref:PDI ("bar")) 0)
            (const_int 0 [0x0]))) -1 (nil)
    (nil)
    (nil))

(call_insn 15 13 17 (set (reg:SI 109)
        (call (mem:PDI (symbol_ref:PDI ("bar")) 0)
            (const_int 0 [0x0]))) -1 (nil)
    (nil)
    (nil))

(insn 21 17 22 (set (reg:SI 110)
        (plus:SI (reg/v:SI 107)
            (reg/v:SI 108))) 47 {addsi3} (nil)
    (nil))

(insn 22 21 24 (set (reg:SI 113)
        (plus:SI (reg:SI 110)
            (reg/v:SI 109))) 47 {addsi3} (nil)
    (nil))
...

The only difference being the introduction of the two new pseudos 111 &
112, which fixes the problem where the definition of 108 & 109 do not
dominate all uses...

-Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]