Hi Will,

On Thu, Aug 16, 2018 at 10:50:45AM -0500, Will Schmidt wrote:
> 2018-08-16  Will Schmidt  <will_schm...@vnet.ibm.com>
> 
>       * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for
>         early gimple folding of vec_splat().

Continuation lines should be indented to the *, not to the text after it.

> +     /* Only fold the vec_splat_*() if arg1 is a constant
> +        5-bit unsigned literal.  */
> +     if (TREE_CODE (arg1) != INTEGER_CST || TREE_INT_CST_LOW (arg1) > 0x1f)
> +       return false;

Does this need to check for negative as well?  So something with IN_RANGE
then.

> +     /* force arg1 into range.  */
> +     tree new_arg1 = build_int_cst (arg1_type,
> +                                    TREE_INT_CST_LOW (arg1) % n_elts);

Or is the range check unnecessary completely, since you have this?

> +     tree splat;
> +     if (TREE_CODE (arg0) == VECTOR_CST)
> +       splat = VECTOR_CST_ELT (arg0, TREE_INT_CST_LOW (new_arg1));
> +     else
> +       {
> +         /* Determine (in bits) the length and start location of the
> +            splat value for a call to the tree_vec_extract helper.  */
> +         int tree_size_in_bits = TREE_INT_CST_LOW (size_in_bytes (arg0_type))
> +                                 * BITS_PER_UNIT;
> +         int splat_elem_size = tree_size_in_bits / n_elts;
> +         int splat_start_bit = TREE_INT_CST_LOW (new_arg1) * splat_elem_size;
> +         /* Do not attempt to early-fold if the size + specified offset into
> +            the vector would touch outside of the source vector.  */
> +         tree len = build_int_cst (bitsizetype, splat_elem_size);
> +         tree start = build_int_cst (bitsizetype, splat_start_bit);
> +         splat = tree_vec_extract (gsi, TREE_TYPE (lhs_type), arg0,
> +                                   len, start);
> +     }

This closing brace should be indented two spaces more.

> -static inline tree
> +tree
>  tree_vec_extract (gimple_stmt_iterator *gsi, tree type,
>                 tree t, tree bitsize, tree bitpos)

It could use a comment, too (what the args are, etc.)

Other than those nits, looks fine to me.  Maybe Richard or Bill have
more comments?


Segher

Reply via email to