[PATCH 3/6] rs6000, Add vector replace builtin support
Segher Boessenkool
segher@kernel.crashing.org
Wed Jun 3 23:40:05 GMT 2020
Hi!
On Mon, Jun 01, 2020 at 09:14:47AM -0700, Carl Love wrote:
> * config/rs6000/altivec.h: Add define for vec_replace_elt and
> vec_replace_unaligned.
* config/rs6000/altivec.h (vec_replace_elt, vec_replace_unaligned):
New defines.
> * config/rs6000/vsx.md: Add unspec UNSPEC_REPLACE_ELT and
> UNSPEC_REPLACE_UN.
> Add mode iterator REPLACE_ELT.
> Add mode attributes REPLACE_ELT_atr, REPLACE_ELT_inst,
> REPLACE_ELT_char, REPLACE_ELT_sh, REPLACE_ELT_max.
> Add define_expand vreplace_elt_<mode>, mode REPLACE_ELT.
> Add define_expand vreplace_un_<mode>, mode REPLACE_ELT.
> Add define_insn vreplace_elt_<mode>_inst, mode REPLACE_ELT.
* config/rs6000/vsx.md (UNSPEC_REPLACE_ELT, UNSPEC_REPLACE_UN): New.
(REPLACE_ELT): New mode iterator.
(REPLACE_ELT_atr, REPLACE_ELT_inst, REPLACE_ELT_char, REPLACE_ELT_sh,
REPLACE_ELT_max): New mode attributes.
(vreplace_elt_<mode>, vreplace_un_<mode>, vreplace_elt_<mode>_inst
for REPLACE_ELT): New.
(etc.)
> (builtin_function_type): Add case statements for
> FUTURE_BUILTIN_VREPLACE_ELT_UV4SI,
> FUTURE_BUILTIN_VREPLACE_ELT_UV2DI,
> FUTURE_BUILTIN_VREPLACE_UN_UV4SI,
> FUTURE_BUILTIN_VREPLACE_UN_UV2DI.
(builtin_function_type) [FUTURE_BUILTIN_VREPLACE_ELT_UV4SI,
FUTURE_BUILTIN_VREPLACE_ELT_UV2DI, FUTURE_BUILTIN_VREPLACE_UN_UV4SI,
FUTURE_BUILTIN_VREPLACE_UN_UV2DI]: New cases.
> + /* Check whether the 3rd argument is an integer constant in the
> range
> + 0 to 3 inclusive. */
> + STRIP_NOPS (arg2);
> + if (TREE_CODE (arg2) != INTEGER_CST || TREE_INT_CST_LOW (arg2) >
> 3)
Hrm, does this test that is it non-negative as well? Maybe it should use
something like
if (TREE_CODE (arg2) != INTEGER_CST
|| !IN_RANGE (TREE_INT_CST_LOW (arg2), 0, 3))
(same below, for 0..12).
> +(define_mode_attr REPLACE_ELT_atr [(V4SI "SI") (V4SF "SF")
> + (V2DI "DI") (V2DF "DF")])
You can use VS_scalar wherever you use this?
> +(define_mode_attr REPLACE_ELT_inst [(V4SI "v4si") (V4SF "v4sf")
> + (V2DI "v2di") (V2DF "v2df")])
This one is just <mode>.
>
> +(define_expand "vreplace_elt_<mode>"
> + [(set (match_operand:REPLACE_ELT 0 "register_operand")
> + (unspec:REPLACE_ELT [(match_operand:REPLACE_ELT 1 "register_operand")
Indent is a bit wrong here (the "unspec" should line up with the
"match_operand").
> + Endianess if needed. */
(two n's in endianness).
I think the rest is fine. Okay for trunk with these things fixed, or
resend it if you prefer?
Thanks!
Segher
More information about the Gcc-patches
mailing list