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: Scheduler: Allow breaking dependencies by modifying patterns


On 08/03/2012 08:05 AM, Bernd Schmidt wrote:
This patch allows us to change

rn++
rm=[rn]

into

rm=[rn + 4]
rn++
That is an interesting optimization. I think analogous optimization could be done for INC/DEC addressing (probably it might be beneficial for ppc which has such addressing and displacement addressing). Although it will complicate the haifa scheduler quite a lot as a new insn is generated and the real benefits are may be not worth of it (as an additional insn should be generated which in many cases it could result even in worse code).
Opportunities to do this are discovered by a mini-pass over the
instructions after generating dependencies and before scheduling a
block. At that point we have all the information required to ensure that
a candidate dep between two instructions is only used to show the
register dependence, and to ensure that every insn with a memory
reference is only subject to at most one dep causing a pattern change.

The dep_t structure is extended to hold an optional pointer to a
"replacement description", which holds information about what to change
when a dependency is broken. The time when this replacement is applied
differs depending on whether the changed insn is the DEP_CON (in which
case the pattern is changed whenever the broken dependency becomes the
last one), or the DEP_PRO, in which case we make the change when the
corresponding DEP_CON has been scheduled. This ensures that the ready
list always contains insns with the correct pattern.

A few additional bits are needed in the dep structure: one to hold
information about whether a dependency occurs multiple times, and one to
distinguish dependencies that are purely for register values from those
with other meanings (e.g. memory references).

Also, sched-rgn was changed to use a new bit, DEP_POSTPONED, rather than
HARD_DEP to indicate that we don't want to schedule an insn in the
current block.

A possible future extension would be to also allow autoinc addressing
modes as the increment insn.

Bootstrapped and tested on x86_64-linux, and also tested on c6x-elf
(quite a number of changes were necessary to make it work there). It was
originally written for a mips target and tested there in the context of
a 4.6 tree. I've also run spec2000 on x86_64, with no change that looked
like anything other than noise. Ok?


Ok, thanks. The changes are pretty straightforward. Only just a few comments.

One is a missed change log entry for haifa_note_dep.

Second one is for

+  /* Cached cost of the dependency.  Make sure to update UNKNOWN_DEP_COST
+     when changing the size of this field.  */
+  int cost:20;
 };

+#define UNKNOWN_DEP_COST (-1<<19)
+

You could use a macro to define bit widths and UNKNOWN_DEP_COST. But probably it is a taste matter.

The third one is success_in_block in find_modifiable_mems. It is calculated but nowhere used. Probably it was used for debugging. You should something to do with this.

Thanks for the patch, Bernd. Sorry for the delay with the review. I thought that Maxim writes his comments first.


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