Hi!

On Tue, Feb 08, 2022 at 03:29:48PM -0600, Bill Schmidt wrote:
> Due to a pasto error in the documentation, vec_replace_unaligned was
> implemented with the same function prototypes as vec_replace_elt.  It was
> intended that vec_replace_unaligned always specify output vectors as having
> type vector unsigned char, to emphasize that elements are potentially
> misaligned by this built-in function.

In the documentation that isn't publically available in the first place,
heh.

I don't see how the result type should always be vector unsigned char
here, and not for every other builtin the same.  But whatever the
documentation says, we should do of course.

> This patch corrects the misimplementation.

> gcc/
>       * config/rs6000/rs6000-builtins.def (VREPLACE_UN_UV2DI): Change
>       function prototype.
>       (VREPLACE_UN_UV4SI): Likewise.
>       (VREPLACE_UN_V2DF): Likewise.
>       (VREPLACE_UN_V2DI): Likewise.
>       (VREPLACE_UN_V4SF): Likewise.
>       (VREPLACE_UN_V4SI): Likewise.
>       * config/rs6000/rs6000-overload.def (VEC_REPLACE_UN): Change all
>       function prototypes.
>       * config/rs6000/vsx.md (vreplace_un_<mode>): Remove define_expand.
>       (vreplace_un_<mode>): New define_insn.
> 
> gcc/testsuite/
>       * gcc.target/powerpc/vec-replace-word-runnable.c: Handle expected
>       prototypes for each call to vec_replace_unaligned.

> +(define_insn "vreplace_un_<mode>"
> + [(set (match_operand:V16QI 0 "register_operand" "=v")
> +  (unspec:V16QI [(match_operand:REPLACE_ELT 1 "register_operand" "0")
> +                 (match_operand:<VS_scalar> 2 "register_operand" "r")
> +              (match_operand:QI 3 "const_0_to_12_operand" "n")]
> +             UNSPEC_REPLACE_UN))]
> + "TARGET_POWER10"
> + "vins<REPLACE_ELT_char> %0,%2,%3"
> + [(set_attr "type" "vecsimple")])

const_0_to_12 operand is wrong for vinsd.  Not new after your patch, but
still broken.  You could use const_0_to_15_operand together with an insn
condition for example.  It seems all uses of 0_to_12 have similar
problems?  Removing it completely also saves use from having to fix its
documentation (in predicates.md) :-)

The patch is okay for trunk.  Thanks!


Segher

Reply via email to