This is the mail archive of the gcc-patches@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: Thread-safe profiling


Hi,

On Wed, 21 Mar 2007, Richard Henderson wrote:

> On Wed, Mar 21, 2007 at 01:19:08PM +0100, Michael Matz wrote:
> > >            (match_operand:SI 3 "register_operand" "c,r")
> > >            (match_operand:SI 4 "register_operand" "c,c")]
> 
> Just remembered... probably want to have "*c,r" there, to 
> avoid preferencing problems.

Hmm, doesn't work unfortunately.  We have these operands of interest then:

(match_operand:SI 3 "register_operand" "*c,r")
(clobber (match_scratch:SI 5 "=&r,X"))

Alternative 2 will unfortunately be better no matter what is assigned to 
operand 3, as the "X" constraint will make that alternative win without 
further consideration for operand 5.  So, all else being equal we have one 
loser less, alternative 2 is chosen, and no register is allocated for 
operand 5, which then later makes alternative 1 never match anymore.  So 
we're back to the problematic case.

The problem is, that we can't express registers sets to avoid in 
constraints, hence reload also doesn't see any reason _not_ to chose 
alternative 2 for operand 3, even if it becomes %ecx.

I now could go on, and make the first alternative be very preferred, but 
that doesn't solve the problem (only makes it unlikely), and it also 
doesn't help us in saving a register, as then the bad case %ecx will be 
chosen; not to speak of the strangeness to prefer an alternative which 
actually is worse.  Or I could make the match_scratch not have "X" as 
constraint, but that would again waste a register for the non-%ecx case, 
where we wanted to save one.

If you have any clever idea (besides implementing negative constraints in 
reload :-) ), I'm all ears, otherwise I'm leaning to just live with the 
suboptimality with -fomit-frame-pointer.  It's not as bad as it sounds, 
because %ebp can still be used, for instance to pass the address of the 
MEM operand to the instruction, so having only %esi and %edi for that 
specific operand is IMHO acceptable.


Ciao,
Michael.


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