public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: local-alloc update_equiv_regs and moving register initialization
@ 2000-09-14 16:41 John Wehle
  2000-09-14 16:54 ` Joern Rennecke
  0 siblings, 1 reply; 9+ messages in thread
From: John Wehle @ 2000-09-14 16:41 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

> consider
> 
>     if (i)
>       c = a + b;
>     a = i * 3;

The optimization in question requires that the register be set and used
exactly once.  I was going with the requirement that the set appear
prior to the use and known to be executed.

Assuming that code (such as that above) is ignored, any other reason
not to move the initialization when both are within the same loop?

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: local-alloc update_equiv_regs and moving register initialization
@ 2000-09-14 17:03 John Wehle
  0 siblings, 0 replies; 9+ messages in thread
From: John Wehle @ 2000-09-14 17:03 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

> a is set and used exactly once, and the set is known to be executed.
> It just happens to come after the use.

Exactly.

> Note that you also have to watch out for cases where the set is statically
> before the use, but dynamically after the use in loop order.

Yes.  I was talking from a CFG point of view.

I'll add moving register initialization within loops to my list of
candidates of things to "play with".  Thanks for pointing out some
of the sharp objects. :-)

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: local-alloc update_equiv_regs and moving register initialization
@ 2000-09-14 16:04 John Wehle
  2000-09-14 16:22 ` Joern Rennecke
  0 siblings, 1 reply; 9+ messages in thread
From: John Wehle @ 2000-09-14 16:04 UTC (permalink / raw)
  To: amylaar; +Cc: gcc

>> Why isn't desirable to move the register initialization just before the
>> use when both are within the same loop?
>
> Because then you might change the semantics of the program.

That's a good reason, however I'm feeling a bit dense.  How could it
change the semantics of the program?  If it's safe to change:

  a = 3;
  ...
  c = a + b;

to

  ...
  a = 3;
  c = a + b;

when a = 3 and c = a + b are outside a loop, why isn't it safe to make
the same change when both are inside the same loop?

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 9+ messages in thread
* local-alloc update_equiv_regs and moving register initialization
@ 2000-09-14 15:44 John Wehle
  2000-09-14 15:56 ` Joern Rennecke
  2000-09-14 16:02 ` Jeffrey A Law
  0 siblings, 2 replies; 9+ messages in thread
From: John Wehle @ 2000-09-14 15:44 UTC (permalink / raw)
  To: gcc

update_equiv_regs has the comment:

  /* Now scan all regs killed in an insn to see if any of them are
     registers only used that once.  If so, see if we can replace the
     reference with the equivalent from.  If we can, delete the
     initializing reference and this register will go away.  If we
     can't replace the reference, and the instruction is not in a
     loop, then move the register initialization just before the use,
     so that they are in the same basic block.  */

Why isn't desirable to move the register initialization just before the
use when both are within the same loop?

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------

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

end of thread, other threads:[~2000-09-14 17:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-14 16:41 local-alloc update_equiv_regs and moving register initialization John Wehle
2000-09-14 16:54 ` Joern Rennecke
  -- strict thread matches above, loose matches on Subject: below --
2000-09-14 17:03 John Wehle
2000-09-14 16:04 John Wehle
2000-09-14 16:22 ` Joern Rennecke
2000-09-14 15:44 John Wehle
2000-09-14 15:56 ` Joern Rennecke
2000-09-14 16:02 ` Jeffrey A Law
2000-09-14 16:09   ` Jeffrey A Law

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).