Message ID | 20150129143554.GB14796@bubble.grove.modra.org |
---|---|
State | New |
Headers | show |
On Fri, Jan 30, 2015 at 01:05:54AM +1030, Alan Modra wrote: > Segher, does this one look better to you? The previous patch turned > off constant propagation for fixed registers as well as register copy > propagation. The latter is all I really meant to do. I'm still not happy about not constant propagating any fixed reg. But if what you really care about is register variables (as in the testcase), you could test for that? Just global register vars or all register vars, either works for me (not that I have to approve it ;-) ) Minor things: > Index: gcc/cprop.c > =================================================================== > --- gcc/cprop.c (revision 219792) > +++ gcc/cprop.c (working copy) > @@ -1207,7 +1207,11 @@ > > if (cprop_constant_p (this_rtx)) > newcnst = this_rtx; > - if (REG_P (this_rtx) && REGNO (this_rtx) >= FIRST_PSEUDO_REGISTER > + if (REG_P (this_rtx) > + && REGNO (this_rtx) >= FIRST_PSEUDO_REGISTER > + /* Don't copy propagate fixed regs. This just tends to > + extend the lifetime of this_rtx to no purpose. */ > + && (REGNO (x) >= FIRST_PSEUDO_REGISTER || !fixed_regs[REGNO (x)]) HARD_REGISTER_P (x) > Index: gcc/testsuite/gcc.target/powerpc/cprophard.c > =================================================================== > --- gcc/testsuite/gcc.target/powerpc/cprophard.c (revision 0) > +++ gcc/testsuite/gcc.target/powerpc/cprophard.c (working copy) > @@ -0,0 +1,13 @@ > +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ > +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ You can drop the default args: /* { dg-skip-if "" { powerpc*-*-darwin* } } */ Should you exclude darwin here, anyway? > +/* { dg-options "-O2" } */ > +/* { dg-final { scan-assembler "ld 2,(24|40)\\(1\\)" } } */ To avoid "toothpick syndrome" you can group with {} instead of "". Cheers, Segher
On Thu, Jan 29, 2015 at 01:27:24PM -0600, Segher Boessenkool wrote: > On Fri, Jan 30, 2015 at 01:05:54AM +1030, Alan Modra wrote: > > Segher, does this one look better to you? The previous patch turned > > off constant propagation for fixed registers as well as register copy > > propagation. The latter is all I really meant to do. > > I'm still not happy about not constant propagating any fixed reg. s/constant/copy/, sorry. Segher
Index: gcc/cprop.c =================================================================== --- gcc/cprop.c (revision 219792) +++ gcc/cprop.c (working copy) @@ -1207,7 +1207,11 @@ if (cprop_constant_p (this_rtx)) newcnst = this_rtx; - if (REG_P (this_rtx) && REGNO (this_rtx) >= FIRST_PSEUDO_REGISTER + if (REG_P (this_rtx) + && REGNO (this_rtx) >= FIRST_PSEUDO_REGISTER + /* Don't copy propagate fixed regs. This just tends to + extend the lifetime of this_rtx to no purpose. */ + && (REGNO (x) >= FIRST_PSEUDO_REGISTER || !fixed_regs[REGNO (x)]) /* Don't copy propagate if it has attached REG_EQUIV note. At this point this only function parameters should have REG_EQUIV notes and if the argument slot is used somewhere Index: gcc/testsuite/gcc.target/powerpc/cprophard.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/cprophard.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/cprophard.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "ld 2,(24|40)\\(1\\)" } } */ + +/* From a linux kernel mis-compile of net/core/skbuff.c. */ +register unsigned long current_r1 asm ("r1"); + +void f (unsigned int n, void (*fun) (unsigned long)) +{ + while (n--) + (*fun) (current_r1 & -0x1000); +}