public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: condition codes, haifa-sched and virtual-stack-vars
@ 2002-01-30 15:19 Ulrich Weigand
  2002-01-30 16:50 ` Geoff Keating
  2002-01-30 19:31 ` Richard Henderson
  0 siblings, 2 replies; 19+ messages in thread
From: Ulrich Weigand @ 2002-01-30 15:19 UTC (permalink / raw)
  To: greg; +Cc: gcc

Greg McGary wrote:

>Here's a summary of mutations, by optimizer phase.

[snip reload generating addsi insn clobbering CC]

>Things would have been OK if the stack var weren't the first one,
>so that it got an offset in 00.rtl, and the associated clobber.
>Maybe we shouldn't emit bare virtual-stack-vars, but rather emit as
>plus with 0 offset?

I've been fighting exactly this problem on s390 ever since
we changed from cc0 to an explicit CC register :-(

The problem is that reload simply calls gen_add2_insn whenever it
feels like it, without consideration that this might introduce
a CC clobber at an inappropriate point ...

The only way I've found around this is to use some insn that
performs an addition without clobbering CC; on many architectures
some sort of 'load-address' instruction can be used for this.
E.g. on i386, every addition reload wants to perform appears to
fit the 'lea' pattern, so they don't have the problem.

On s390, while we do have a load-address pattern, it is somewhat
restricted (e.g. it accepts only immediate offsets in the 0..4095
range).  I've tried to trick reload into using LA anyway, by 
providing a generic 'add' pattern and splitters to massage the
result into a form acceptable by LA afterward.

There might be other options, e.g. converting addsi3 into an
expander that generates different code when called while
reload_in_progress, or using a secondary input reload to 
handle PLUS reloads ...

If you don't have any sort of load-address instruction, I don't
know what to do either.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de

^ permalink raw reply	[flat|nested] 19+ messages in thread
[parent not found: <no.id>]
* condition codes, haifa-sched and virtual-stack-vars
@ 2002-01-30 12:31 Greg McGary
  2002-01-30 12:42 ` law
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Greg McGary @ 2002-01-30 12:31 UTC (permalink / raw)
  To: gcc

I have a GCC port to a custom RISC that uses condition codes in an
explicit register (doesn't use cc0).  GCC generates bogus code when
expanding an inline.  One of the inline's args is the address of an
automatic, so it is passed to the inline as a move from
virtual-stack-vars to a pseudo.  Later, there's a conditional branch
on bitfield test that expands as bitfield-extract (shift + and),
comparison wtih zero, and branch.  All harmless so far.

Haifa-sched schedules the move from virtual-stack-vars between the
bitfield test sequence and the branch.  Later, global-reg alloc
instantiates virtual-stack-vars as an offset from FP, so the move
mutates into an add of fp+offset, clobbering the condition codes
computed earlier in the bitfield test.

One idea for a localized bandaid is to make the machine-description
wrap moves from virtual-stack-vars in a parallel that has a clobber
CC_REGNUM.  Another idea is to manipulate scheduling parameters so
that haifa doesn't schedule anything between CC set and CC use.
(I haven't yet looked at if/how this can be done.)

What's a better way to fix it?

Thanks,
Greg

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2002-01-31 22:54 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-30 15:19 condition codes, haifa-sched and virtual-stack-vars Ulrich Weigand
2002-01-30 16:50 ` Geoff Keating
2002-01-30 17:13   ` Ulrich Weigand
2002-01-31 13:59     ` Geoff Keating
2002-01-30 19:31 ` Richard Henderson
2002-01-31 16:07   ` Ulrich Weigand
     [not found] <no.id>
2002-01-30 17:36 ` Ulrich Weigand
  -- strict thread matches above, loose matches on Subject: below --
2002-01-30 12:31 Greg McGary
2002-01-30 12:42 ` law
2002-01-30 13:30   ` Greg McGary
2002-01-30 14:15     ` law
2002-01-31  7:49     ` Richard Earnshaw
2002-01-30 13:56 ` Alexandre Oliva
2002-01-30 17:13   ` Greg McGary
2002-01-30 17:20     ` Alexandre Oliva
2002-01-30 18:00       ` law
2002-01-30 19:23         ` Greg McGary
2002-01-31  5:53           ` Alexandre Oliva
2002-01-30 18:41 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).