[PATCH RFA] Implement register pressure directed hoist pass

Bin Cheng bin.cheng@arm.com
Fri Sep 28 08:21:00 GMT 2012


Hi,

This patch implements register pressure directed hoist pass. Basically it
calculates register pressure for each basic block and use that information
to determine the hoist distance of each candidate expression. The register
pressure is calculated by re-using IRA utilities.

I measured the benefit on Thumb1/Thumb2/ARM/x86/MIPS instruction sets and
targets. For CSiBE, it improves code size by more than 0.1% on thumb1/ARM
instruction set; it improves code size nearly 0.2% on MIPS, all with very
small regressions. Since the hoist itself improves code size by only about
0.1% on Thumb1 instruction set, this is considerable improvement.
Unfortunately this patch has no obvious effect on Thumb2 and X86, so
currently I enabled it on Thumb1 when optimizing for size. Other targets can
take advantage of it as necessary after upstream.

Apart from the change in hoist pass, this patch also changes prototype of
function ira_set_pseudo_classes in IRA. This change is to make IRA
re-calculate cost information by itself, rather than re-using the info
calculated by hoist pass, because hoist is an early pass and the information
cannot be used directly in IRA. You can refer to
http://gcc.gnu.org/ml/gcc/2012-08/msg00299.html for some discussion.

I bootstrap gcc x86_64 on trunk r190769, since the head revision when I was
working on this fails bootstrap that time. The results are:
	bootstrap                        time(real/user/sys)
	trunk/Os                         122m9s/118m30s/19m48s
	patched/Os                       122m20s/118m19s/19m52s
	patched/Os/fira-hoist-pressure   120m47s/119m9s/19m38s
It seems the patch has no obvious slowdown on gcc compilation time. I also
measured miscellaneous binaries generated like cc1/cc1plus, the code size of
text section has been improved by only 0.05% on x86_64, not as obvious as
ARM/MIPS(0.1-0.2%).

I ran regression test on cortex-m3/cortex-m0/X86 with Os and everything was
fine.

Is it ok for upstream?

Thanks

2012-09-28  Bin Cheng  <bin.cheng@arm.com>

	* common.opt (flag_ira_hoist_pressure): New.
	* doc/invoke.texi (-fira-hoist-pressure): Describe.
	* ira-costs.c (ira_set_pseudo_classes): New parameter.
	* ira.h (ira_set_pseudo_classes): Update prototype.
	* haifa-sched.c (sched_init): Update call.
	* ira.c (ira): Update call.
	* regmove.c (regmove_optimize): Update call.
	* loop-invariant.c (move_loop_invariants): Update call.
	* gcse.c (struct bb_data): New structure.
	(BB_DATA): New macro.
	(curr_bb, curr_regs_live, curr_reg_pressure, regs_set, n_regs_set):
New
	static variables.
	(hoist_expr_reaches_here_p): Use reg pressure to determin the
distance
	expr can be hoisted.
	(hoist_code): Use reg pressure to direct the hoist process.
	(get_regno_pressure_class, get_pressure_class_and_nregs)
	(change_pressure, mark_regno_live, mark_regno_death, mark_reg_death)
	(mark_reg_store, mark_reg_clobber, calculate_bb_reg_pressure)
	(free_bb_data): New.
	(one_code_hoisting_pass): Calculate register pressure. Free data.
	* config/arm/arm.c (arm_option_override): Set
flag_ira_hoist_pressure
	on Thumb1 when optimizing for size.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hoist-reg-pressure-20120928.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120928/c2e20f4e/attachment.txt>


More information about the Gcc-patches mailing list