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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-05-25
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |rguenth at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
using V [[gnu::vector_size(16)]] = short;

V f(V s)
{
  return V{
    short(1) >> s[0],
    short(1) >> s[1],
    short(1) >> s[2],
    short(1) >> s[3],
    short(1) >> s[4],
    short(1) >> s[5],
    short(1) >> s[6],
    short(1) >> s[7]
    };
}

the frontend gives us

return <retval> = {(short int) (1 >> (int) VIEW_CONVERT_EXPR<short
int[8]>(s)[0]), (short int) (1 >> (int) VIEW_CONVERT_EXPR<short int[8]>(s)[1]),
(short int) (1 >> (int) VIEW_CONVERT_EXPR<short int[8]>(s)[2]), (short int) (1
>> (int) VIEW_CONVERT_EXPR<short int[8]>(s)[3]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[4]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[5]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[6]), (short int) (1 >> (int)
VIEW_CONVERT_EXPR<short int[8]>(s)[7])};

and the promotion/demotion stays until eventually basic-block vectorization
vectorizes this without doing the promotion.

t.ii:14:5: note:   vect_recog_over_widening_pattern: detected: _3 = 1 >> _2;
t.ii:14:5: note:   demoting int to signed short
t.ii:14:5: note:   created pattern stmt: patt_36 = 1 >> _1;

I don't think there's any way to query the target about whether vector
shifts "behave".

We end up with

V f (V s)
{
  vector(8) signed short vect_patt_36.3;

  <bb 2> [local count: 1073741824]:
  vect_patt_36.3_62 = { 1, 1, 1, 1, 1, 1, 1, 1 } >> s_33(D);
  return vect_patt_36.3_62;

Reply via email to