recursive rtl bug

Bernd Schmidt bernds@murgh.cygnus.co.uk
Fri Dec 31 16:38:00 GMT 1999


On Thu, 16 Dec 1999, Richard Kenner wrote:

> + 	* combine.c (combine_simplify_rtx): Don't make shared rtl.
> 
> Why not?  There are calls to copy_rtx_if_shared in try_combine.
> 
> It's *perfectly* valid to share rtx in combine!

We have three insns in try_combine.  First, we substitute i2 into i3; this
is where we generate shared rtl.  At this point, newpat looks like

(set (reg:DF 50)
    (plus:DF (mult:DF (mem:DF (reg/v:SI 41) 3)
            (mem/s:DF (plus:SI (mult:SI (reg/v:SI 43)
                        (const_int 8 [0x8]))
                    (reg/v:SI 40)) 3))
        (mult:DF (reg:DF 48)
            (mem/s:DF (plus:SI (mult:SI (reg/v:SI 43)
                        (const_int 8 [0x8]))
                    (reg/v:SI 40)) 3))))

Then, we substitute i1 into this.
  i1dest = (reg/v:SI 43)
  i1src = (plus:SI (plus:SI (reg/v:SI 43)
			    (reg/v:SI 44))
		   (const_int 1 [0x1]))

After substituting inside the first argument of the outer PLUS, we have
(in subst, while looping over the arguments of the PLUS):

(plus:DF (mult:DF (mem:DF (reg/v:SI 41) 3)
        (mem/s:DF (plus:SI (plus:SI (mult:SI (plus:SI (reg/v:SI 43)
                            (reg/v:SI 44))
                        (const_int 8 [0x8]))
                    (reg/v:SI 40))
                (const_int 8 [0x8])) 3))
    (mult:DF (reg:DF 48)
        (mem/s:DF (plus:SI (plus:SI (mult:SI (plus:SI (reg/v:SI 43)
                            (reg/v:SI 44))
                        (const_int 8 [0x8]))
                    (reg/v:SI 40))
                (const_int 8 [0x8])) 3)))

Note how both arguments changed although we only substituted inside
the first.
Then we substitute again, inside the second argument of the PLUS, and
end up generating circular rtl.  This is basically the effect of
substituting reg 43 with i1src in i1src itself.


Bernd



More information about the Gcc-patches mailing list