[PATCH] Fix PR63266: Keep track of impact of sign extension in bswap

Thomas Preud'homme thomas.preudhomme@arm.com
Tue Sep 16 10:27:00 GMT 2014

Hi all,

The fix for PR61306 disabled bswap when a sign extension is detected. However this led to a test case regression (and potential performance regression) in case where a sign extension happens but its effect is canceled by other bit manipulation. This patch aims to fix that by having a special marker to track bytes whose value is unpredictable due to sign extension. If the final result of a bit manipulation doesn't contain any such marker then the bswap optimization can proceed.

*** gcc/ChangeLog ***

2014-09-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	PR tree-optimization/63266
	* tree-ssa-math-opts.c (struct symbolic_number): Add comment about
	marker for unknown byte value.
	(MARKER_MASK): New macro.
	(HEAD_MARKER): New macro.
	(do_shift_rotate): Mark bytes with unknown values due to sign
	extension when doing an arithmetic right shift. Replace hardcoded
	mask for marker by new MARKER_MASK macro.
	(find_bswap_or_nop_1): Likewise and adjust ORing of two symbolic
	numbers accordingly.

*** gcc/testsuite/ChangeLog ***

2014-09-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	PR tree-optimization/63266
	* gcc.dg/optimize-bswapsi-1.c (swap32_d): New bswap pass test.


* Built an arm-none-eabi-gcc cross-compiler and used it to run the testsuite on QEMU emulating Cortex-M3 without any regression
* Bootstrapped on x86_64-linux-gnu target and testsuite was run without regression

Ok for trunk?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr63266.1.1.diff
Type: application/octet-stream
Size: 5706 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140916/790c12cf/attachment.obj>

More information about the Gcc-patches mailing list