[RFC] Fix PR rtl-optimization/59461

Eric Botcazou ebotcazou@adacore.com
Mon Nov 7 10:39:00 GMT 2016


It's a missed optimization of a redundant zero-extension on the SPARC, which 
originally comes from PR rtl-optimization/58295 for ARM.  The extension is 
eliminated on the ARM because the load is explicitly zero-extended in RTL;
on the SPARC the load is implicitly zero-extended by means of LOAD_EXTEND_OP 
and the combiner is blocked by limitations of the nonzero_bits machinery.

The approach is two-pronged:
 1. it lifts a limitation in reg_nonzero_bits_for_combine that was recently 
added (https://gcc.gnu.org/ml/gcc-patches/2013-11/msg03782.html) and prevents 
the combiner from reasoning on larger modes under certain circumstances.
 2. it makes nonzero_bits1 propagate results from inner REGs to paradoxical 
SUBREGs if both WORD_REGISTER_OPERATIONS and LOAD_EXTEND_OP are set.

This also eliminate quite a few zero-extensions in the compile.exp testsuite 
at -O2 on the SPARC.  Tested on x86-64/Linux and SPARC/Solaris.


2016-11-07  Eric Botcazou  <ebotcazou@adacore.com>

	PR rtl-optimization/59461
	* doc/rtl.texi (paradoxical subregs): Add missing word.
	* combine.c (reg_nonzero_bits_for_combine): Do not discard results
	in modes with precision larger than that of last_set_mode.
	* rtlanal.c (nonzero_bits1) <SUBREG>: If WORD_REGISTER_OPERATIONS is
	set and LOAD_EXTEND_OP is appropriate, propagate results from inner
	REGs to paradoxical SUBREGs.
	(num_sign_bit_copies1) <SUBREG>: Likewise.  Check that the mode is not
	larger than a word before invoking LOAD_EXTEND_OP on it.


2016-11-07  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.target/sparc/pr59461.c: New test.

-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr59461.c
Type: text/x-csrc
Size: 339 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161107/8bbccfe8/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr59461.diff
Type: text/x-patch
Size: 6277 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161107/8bbccfe8/attachment-0001.bin>


More information about the Gcc-patches mailing list