https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107432

--- Comment #5 from Hongtao.liu <crazylht at gmail dot com> ---

> It's lowered by pass_lower_vector, ideally, can we use truncmn2 in
> expand_VEC_CONVERT if src is bigger integer mode than dest.

Currently, expand_vector_conversion uses VEC_PACK_TRUNC_EXPR

---------------cut begins------------------------
  else if (modifier == NARROW)
    {
      switch (code)
        {
        CASE_CONVERT:
          code1 = VEC_PACK_TRUNC_EXPR;
          optab1 = optab_for_tree_code (code1, arg_type, optab_default);
          break;

---------------Cut ends------------------------

But BB vectorizer can do the right thing for 

void
foo (long long* a, int* b)
{
    b[0] = a[0];
    b[1] = a[1];
    b[2] = a[2];
    b[3] = a[3];
}



        vmovdqu ymm0, YMMWORD PTR [rdi]
        vpmovqd XMMWORD PTR [rsi], ymm0
        vzeroupper
        ret


  vect__1.5_16 = MEM <vector(4) long long int> [(long long int *)a_10(D)];
  vect__2.6_18 = (vector(4) int) vect__1.5_16;
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  MEM <vector(4) int> [(int *)b_11(D)] = vect__2.6_18;
  return;


Guess expand_vector_conversion can be optimized.

Reply via email to