On Mon, Oct 19, 2020 at 10:21 AM Hongtao Liu <crazy...@gmail.com> wrote:
>
> Hi:
>   It's implemented as below:
> V setg (V v, int idx, T val)
>
> {
>   V idxv = (V){idx, idx, idx, idx, idx, idx, idx, idx};
>   V valv = (V){val, val, val, val, val, val, val, val};
>   V mask = ((V){0, 1, 2, 3, 4, 5, 6, 7} == idxv);
>   v = (v & ~mask) | (valv & mask);
>   return v;
> }
>
> Bootstrap is fine, regression test for i386/x86-64 backend is ok.
> Ok for trunk?

Hmm, I guess you're trying to keep the code for !AVX512BW simple
but isn't just splitting the compare into

 clow = {0, 1, 2, 3 ... } == idxv
 chigh = {16, 17, 18, ... } == idxv;
 cmp = {clow, chigh}

faster, smaller and eventually even easier during expansion?

+  gcc_assert (ix86_expand_vector_init_duplicate (false, mode, valv, val));
+  gcc_assert (ix86_expand_vector_init_duplicate (false, cmp_mode,
idxv, idx_tmp));

side-effects in gcc_assert is considered bad style, use

  ok = ix86_expand_vector_init_duplicate (false, mode, valv, val);
  gcc_assert (ok);

+  vec[5] = constv;
+  ix86_expand_int_vcond (vec);

this also returns a bool you probably should assert true.

Otherwise thanks for tackling this.

Richard.

> gcc/ChangeLog:
>
>         PR target/97194
>         * config/i386/i386-expand.c (ix86_expand_vector_set_var): New 
> function.
>         * config/i386/i386-protos.h (ix86_expand_vector_set_var): New Decl.
>         * config/i386/predicates.md (vec_setm_operand): New predicate,
>         true for const_int_operand or register_operand under TARGET_AVX2.
>         * config/i386/sse.md (vec_set<mode>): Support both constant
>         and variable index vec_set.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/avx2-vec-set-1.c: New test.
>         * gcc.target/i386/avx2-vec-set-2.c: New test.
>         * gcc.target/i386/avx512bw-vec-set-1.c: New test.
>         * gcc.target/i386/avx512bw-vec-set-2.c: New test.
>         * gcc.target/i386/avx512f-vec-set-2.c: New test.
>         * gcc.target/i386/avx512vl-vec-set-2.c: New test.
>
> --
> BR,
> Hongtao

Reply via email to