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]

[PATCH] Fix latent bug in reload_combine


This patch fixes a bug that was originally reported against gcc-3.2.x.  It 
seems to have gone latent in the current sources which is why it has been 
languishing on my to-do list for way too long now.

The problem occurs with the optimization:

        (set (REGX) (CONST_INT))
        (set (REGX) (PLUS (REGX) (REGY)))
        ...
        some use of  REGX

being transformed into:

        (set (REGZ) (CONST_INT))
        ...
        some use of (PLUS (REGZ) (REGY))

The problem case being REGX == REGY.  In this case REGY is killed by the 
second set of the orginal sequence.  In other words we had the sequence

	set (rx) (1)
	set (rx) (plus (rx) (rx))	; rx == 2
	some use of (plus (rx) 1)	

but we transformed this into (by factoring the +1 into the initial 
constant)

	set (rx) (2)
	some use of (plus (rx) (rx))

What we've failed to do is to note that REGY was killed in the insn we are 
removing and thus that we can't alter the constant that preceded it.

The problem comes from the fact that we haven't done any data-flow 
analysis on the insn that we are currently processing (the middle insn) so 
we miss the fact that REGY has been killed.  Fixing this is a trivial test 
at the start of the section.

Since the 3.2 branch is dead, and the bug has gone latent elsewhere, I'm 
only checking this change in on the trunk.

R.

2003-10-31  Richard Earnshaw  <rearnsha@arm.com>

	* postreload.c (reload_combine): Check that REGY doesn't die in an
	insn of the form (set (regx) (plus (regx) (regy))), ie REGX != REGY.


Attachment: reload_combine.patch
Description: reload_combine.patch


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