https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129050
Bug ID: 129050
Summary: BF16 __builtin_fabsf16/negation loops no longer
vectorize after match.pd float-conversion change
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: yansendao at 126 dot com
Target Milestone: ---
On trunk, the match.pd change for PR128460/PR128912 stopped folding
_Float16 <-> __bf16 conversion chains, and as a side effect the loops in
the BF16 abs/neg tests are no longer vectorized.
Introduced by:
commit 95decbde1acc0c9a459d39e806106ab4e232085a
"match.pd: Only fold float conversion chains through a format that holds
the input [PR128460] [PR128912]"
That commit replaced the old element_precision comparison in the
"two conversions in a row" rule with real_exact_conversion_p, because
_Float16 and __bf16 have the same width but different mantissa/exponent
ranges (the commit message names them explicitly). __builtin_fabsf16 and
negation on a __bf16 array require a __bf16 -> _Float16 conversion, which
the vectorizer now reports as unsupported:
missed: not vectorized: relevant stmt not supported: _3 = (_Float16) _2;
Failing on x86_64 (trunk @ 5ea58c9d725146c20854720dba46175add86bac6):
FAIL: gcc.target/i386/avx2-bf16-vec-absneg.c scan-tree-dump-times optimized
"(?n)ABS_EXPR <vect" 2
FAIL: gcc.target/i386/avx2-bf16-vec-absneg.c scan-tree-dump-times vect "loop
vectorized using 16 byte vectors" 2
FAIL: gcc.target/i386/avx2-bf16-vec-absneg.c scan-tree-dump-times vect "loop
vectorized using 32 byte vectors" 2
FAIL: gcc.target/i386/avx512f-bf16-vec-absneg.c scan-tree-dump-times
optimized "(?n)ABS_EXPR <vect" 1
FAIL: gcc.target/i386/avx512f-bf16-vec-absneg.c scan-tree-dump-times vect
"loop vectorized using 64 byte vectors" 2
FAIL: gcc.target/i386/part-vect-absnegbf.c scan-tree-dump-times optimized
"(?n)ABS_EXPR <vect" 2
FAIL: gcc.target/i386/part-vect-absnegbf.c scan-tree-dump-times vect "loop
vectorized using 8 byte vectors" 2
Reproduce:
make check-gcc RUNTESTFLAGS="i386.exp=avx2-bf16-vec-absneg.c"
With -O1 -mavx512bf16 -fdump-tree-vect-details, only the two fabs loops
still vectorize; the negation loops are rejected by the vectorizer on the
_Float16 conversion above.