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

            Bug ID: 129071
           Summary: Missed vectorization of conversions between __bf16 and
                    _Float16
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yansendao at 126 dot com
  Target Milestone: ---

Applying a _Float16 operation such as __builtin_fabsf16 to a __bf16 value
introduces a __bf16 -> _Float16 conversion (and a _Float16 -> __bf16
conversion for the store).  Since r17-6689 (match.pd: only fold float
conversion chains through a format that holds the input, PR128460/PR128912)
these conversions are no longer folded away — correctly, because the fold
was wrong code — but the vectorizer now rejects the loop:

  missed: not vectorized: relevant stmt not supported: _3 = (_Float16) _2;

so this no longer vectorizes for __bf16 arrays (with -O2 -mavx512bf16):

  __bf16 r[8], b[8];
  void f (void) {
    for (int i = 0; i < 8; i++)
      r[i] = __builtin_fabsf16 (b[i]);
  }

__bf16 and _Float16 have the same width but different mantissa/exponent
ranges, so the conversion is semantically required and cannot be dropped.
It could be done via float (__bf16 -> float -> _Float16), but
supportable_convert_operation does not handle that multi-step path and
gives up.

PR middle-end/129050 updated the tests to use __builtin_fabsf as a
workaround, but the underlying vectorization gap remains.  Richard Biener
suggested tracking this (and recalled Mike had a similar issue).

Related: PR middle-end/129050, PR middle-end/128460, PR middle-end/128912.

Reply via email to