[PATCH][RFC] Updated: Meta-description for tree and gimple folding

Marc Glisse marc.glisse@inria.fr
Fri Mar 7 14:43:00 GMT 2014


(extremely minor comments, not directly related to the machinery)

On Fri, 7 Mar 2014, Richard Biener wrote:

> + /* fold_negate_exprs convert - (~A) to A + 1.  */
> + (match_and_simplify
> +   (negate (bit_not @0))
> +   if (INTEGRAL_TYPE_P (TREE_TYPE (@0)))
> +   (plus @0 { build_int_cst (TREE_TYPE (@0), 1); } ))

We are obviously not at the stage of reviewing individual patterns, but
it would be nice to keep in mind, while doing this, that a lot of those
transformations (most of them?) should apply just the same to vectors.
So it should be easy to test: the type is integral or a vector of
integers (and maybe complex as well, with the subtlety that sometimes
the constant 1 should be 1+0i, but for this transformation it should be
1+i), something is either the constant 2 or a vector of 2, etc, and
build a constant.

> + /* (x >> 31) & 1 -> (x >> 31).  Folding in fold-const is more
> +    complicated here, it does
> +      Fold (X << C1) & C2 into (X << C1) & (C2 | ((1 << C1) - 1))
> +      (X >> C1) & C2 into (X >> C1) & (C2 | ~((type) -1 >> C1))
> +      if the new mask might be further optimized.  */
> + (match_and_simplify
> +   (bit_and (rshift@0 @1 INTEGER_CST_P@2) integer_onep)
> +   if (compare_tree_int (@2, TYPE_PRECISION (TREE_TYPE (@1)) - 1) == 0)
> +   @0)

s/TYPE_PRECISION/element_precision/ will make it easier to port to
vectors. I think this transformation shouldn't output x>>31 but
(unsigned)x>>31, that would give an example of how to convert in this
language.

-- 
Marc Glisse



More information about the Gcc-patches mailing list