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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(simplify
 (BIT_FIELD_REF (view_convert @0) @1 @2)
 (if (! INTEGRAL_TYPE_P (TREE_TYPE (@0))
      || type_has_mode_precision_p (TREE_TYPE (@0)))
  (BIT_FIELD_REF @0 @1 @2)))

/* Fold REDUC (@0 & @1) -> @0[I] & @1[I] if element I is the only nonzero
   element of @1.  */
(for reduc (IFN_REDUC_PLUS IFN_REDUC_IOR IFN_REDUC_XOR)
 (simplify (reduc (view_convert? (bit_and @0 VECTOR_CST@1)))
  (with { int i = single_nonzero_element (@1); }
   (if (i >= 0)
    (with { tree elt = vector_cst_elt (@1, i);
            tree elt_type = TREE_TYPE (elt);
            unsigned int elt_bits = tree_to_uhwi (TYPE_SIZE (elt_type));
            tree size = bitsize_int (elt_bits);
            tree pos = bitsize_int (elt_bits * i); }
     (view_convert
      (bit_and:elt_type
       (BIT_FIELD_REF:elt_type @0 { size; } { pos; })
       { elt; })))))))

Which is we have:
  _2 = _1 & { 4 };
  _16 = VIEW_CONVERT_EXPR<vector(2) long int>(_2);
  _15 = _16;
  _17 = .REDUC_IOR (_15);

Reply via email to