This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Global constant propagation
On Sun, Apr 04, 1999 at 05:47:47AM -0600, Jeffrey A Law wrote:
>
> In message <19990404133100.A3351@daimi.au.dk>you write:
> >
> > Here is a small C fn:
> >
> > int testfn(int a, int b)
> > {
> > a = 1;
> > if(b == 1)
> > {
> > b = 2;
> > }
> > else
> > {
> > b = 3;
> > }
> > return a*b;
> > }
>
> If the if-then-else is confusing cprop, then that would be a bug.
It turns out it isn't. The problem is that on MIPS the
multiplication is inside a PARALLEL rtl (due to the clobbers
of the HI and LO registers as far as I can see), which means
the code in gcse.c can't recognise it and doesn't propagate
the a=1 into it (see cprop_insn). Looks like this:
(insn 34 51 36 (parallel[
(set (reg:SI 85)
(mult:SI (reg/v:SI 81)
(reg/v:SI 82)))
(clobber (scratch:SI))
(clobber (scratch:SI))
(clobber (scratch:SI))
] ) 57 {mulsi3_r4000} (nil)
(nil))
If the a=1 and the multiplication are in the same basic block
then it is spotted by the code in combine, which understands
parralels better (it seems to be doing a rather complete
constant propagation of its own, though not much across basic
blocks).
A solution might be to get gcse.c to recognise parallels that
consist only of a 'set' and some clobbers and treat them like
'set's. I'm not really into this enough to do that...
--
Erik Corry erik@arbat.com Ceterum censeo, Microsoftem esse delendam!