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

            Bug ID: 101540
           Summary: CONSTRUCTOR for vector(1) should just be VCE
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

I noticed with the following source:
typedef unsigned char __attribute__((__vector_size__ (1))) W;
typedef unsigned char __attribute__((__vector_size__ (8))) V;
typedef unsigned short __attribute__((__vector_size__ (16))) U;

unsigned short us;

W
foo (unsigned char uc)
{
  V v = __builtin_convertvector ((U){ } >= us, V);
  return __builtin_shufflevector ((W){ }, v, 4) & uc;
}

int
main (void)
{
  W x = foo (5);
  if (x[0] != 5)
    __builtin_abort();
  return 0;
}
----- CUT ----
We produce
_6 = {uc_10(D)};
But this should be the same as
_6 = VIEW_CONVERT_EXPR<uc_10>

--- CUT ---
This is what we get in the IR:
  _6 = {uc_10(D)};
  _14 = BIT_FIELD_REF <_4, 8, 0>;
  _15 = VIEW_CONVERT_EXPR<unsigned char>(_6);
  _16 = _14 & _15;
  _17 = VIEW_CONVERT_EXPR<W>(_16);

We do change the BIT_FIELD_REF that was assigned to _15 to a VCE though.

Reply via email to