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]

Re: PATCH: Don't rename registers in CLOBBERs


Mark Mitchell <mark@codesourcery.com> writes:

> This patch: 
> 
>   2000-06-26  Geoff Keating  <geoffk@cygnus.com>
> 
> 	(rename_insn_1): Use the new functions.  Handle CLOBBERS.  Handle
> 
> broke the -fssa bootstrap on i686-pc-linux.  It doesn't make sense to
> rename CLOBBERs because in something like this:
> 
>   (set (reg 27) (const_int 3))
>   (clobber (reg 27))
> 
> you end up with a different registered being clobbered than the one
> that was set.

How is this bad?

In a sequence like

(set:SI (reg:SI 27) (const_int 3))
(clobber (reg:SI 27))
(use (reg:SI 27))

it will end up looking like:

(set:SI (reg:SI 27) (const_int 3))
(clobber (reg:SI 1027))
(use (reg:SI 1027))

which breaks the false dependency on register 27 (and effectively
makes the CLOBBER obsolete).

How does code like this get generated?

> Perhaps there is another case that I can't think of?

I belive there are actually only two ways that CLOBBERs get used at
this point in the compilation.  One is subroutine return values, which
aren't handled by this code because they use hard regs.  The other is
for SUBREGs:

(set:DI (reg:DI 27) (const_int 3))
(clobber (reg:DI 27))
(set:DI (subreg:SI (reg:DI 27) 0) (const_int 4))
(set:DI (subreg:SI (reg:DI 27) 1) (const_int 5))

before your change this will turn into:

(set:DI (reg:DI 27) (const_int 3))
(clobber (reg:DI 1027))
(sequence [
  (set:DI (reg:DI 1127) (reg:DI 1027))
  (set:DI (subreg:SI (reg:DI 1127) 0) (const_int 4))
])
(sequence [
  (set:DI (reg:DI 1227) (reg:DI 1127))
  (set:DI (subreg:SI (reg:DI 1227) 1) (const_int 5 )
])

with your patch it will become:

(set:DI (reg:DI 27) (const_int 3))
(clobber (reg:DI 27))
(sequence [
  (set:DI (reg:DI 1027) (reg:DI 27))
  (set:DI (subreg:SI (reg:DI 1027) 0) (const_int 4))
])
(sequence [
  (set:DI (reg:DI 1127) (reg:DI 1027))
  (set:DI (subreg:SI (reg:DI 1127) 1) (const_int 5))
])

which now has a false dependency involving register 27.

In the future, I want it to become:

(set:DI (reg:DI 27) (const_int 3))
(clobber (reg:DI 1027))
(sequence [
  (clobber:DI (reg:DI 1127))
  (set:DI (subreg:SI (reg:DI 1127) 0) (const_int 4))
])
(sequence [
  (set:DI (reg:DI 1227) (reg:DI 1127))
  (set:DI (subreg:SI (reg:DI 1227) 1) (const_int 5))
])

or perhaps even:

(set:DI (reg:DI 27) (const_int 3))
(clobber (reg:DI 1027))
(sequence [
  (clobber:DI (reg:DI 1127))
  (set:DI (subreg:SI (reg:DI 1127) 0) (const_int 4))
  (set:DI (subreg:SI (reg:DI 1127) 1) (const_int 5))
])

but to do this I need to keep track of when the register was last
CLOBBERed or SET, and rather than building a separate data structure I
claim it's easier to just use the existing machinery for tracking SETs
to also track CLOBBERs.  I also want the CLOBBER to be added if it
isn't there and the register wasn't set previously, for which you need
to look at the SETs anyway.
-- 
- Geoffrey Keating <geoffk@cygnus.com>

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