[embedded-5-branch][PATCH 1/2] Backporting algorithmic optimization in match and simplify

Andre Vieira Andre.SimoesDiasVieira@arm.com
Tue Nov 17 09:34:00 GMT 2015


New algorithmic optimisations:
((X inner_op C0) outer_op C1)
    With X being a tree where value_range has reasoned certain bits to 
always be
    zero throughout its computed value range, we will call this the 
zero_mask,
    and with inner_op = {|,^}, outer_op = {|,^} and inner_op != outer_op.
    if (inner_op == '^') C0 &= ~C1;
    if ((C0 & ~zero_mask) == 0) then emit (X outer_op (C0 outer_op C1)
    if ((C1 & ~zero_mask) == 0) then emit (X inner_op (C0 outer_op C1)

(X {&,^,|} C2) << C1 -> (X << C1) {&,^,|} (C2 << C1)
(X {&,^,|} C2) >> C1 -> (X >> C1) & (C2 >> C1)

The second and third transformations enable more applications of the 
first. Also some targets may benefit from delaying shift operations. I 
am aware that such an optimization, in combination with one or more 
optimizations that cause the reverse transformation, may lead to an 
infinite loop. Though such behavior has not been detected during 
regression testing and bootstrapping on aarch64.

This patch backports the optimization from trunk to the embedded-5-branch.

The original patches are at:
https://gcc.gnu.org/ml/gcc-patches/2015-08/msg01493.html (for the first 
optimization and changes to second and third)
https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00517.html (the addition 
of the original second and third optimizations)

gcc/ChangeLog:

2015-11-27  Andre Vieira  <andre.simoesdiasvieira@arm.com>
Backport from mainline:

   2015-10-09  Andre Vieira  <andre.simoesdiasvieira@arm.com>

         * match.pd: ((X inner_op C0) outer_op C1) New pattern.
         ((X & C2) << C1): Expand to...
         (X {&,^,|} C2 << C1): ...This.
         ((X & C2) >> C1): Expand to...
         (X {&,^,|} C2 >> C1): ...This.
   2015-07-07  Richard Biener  <rguenther@suse.de>

	* fold-const.c (fold_binary_loc): Move
	(X & C2) << C1 -> (X << C1) & (C2 << C1) simplification ...
	* match.pd: ... here.


gcc/testsuite/ChangeLog:

2015-11-27  Andre Vieira  <andre.simoesdiasvieira@arm.com>
Backport from mainline:

   2015-10-09  Andre Vieira  <andre.simoesdiasvieira@arm.com>
             Hale Wang  <hale.wang@arm.com>

         * gcc.dg/tree-ssa/forwprop-33.c: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-backport-algorithmic-optimization.patch
Type: text/x-patch
Size: 6022 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20151117/af33b5f6/attachment.bin>


More information about the Gcc-patches mailing list