public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108902] New: Conversions std::float16_t<->float with FP16C are not vectorized
@ 2023-02-23 11:02 g.peterhoff@t-online.de
2023-02-23 11:10 ` [Bug c++/108902] " jakub at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: g.peterhoff@t-online.de @ 2023-02-23 11:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108902
Bug ID: 108902
Summary: Conversions std::float16_t<->float with FP16C are not
vectorized
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: g.peterhoff@t-online.de
Target Milestone: ---
Please see
https://godbolt.org/z/dGn4qhPef
thx
Gero
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/108902] Conversions std::float16_t<->float with FP16C are not vectorized
2023-02-23 11:02 [Bug c++/108902] New: Conversions std::float16_t<->float with FP16C are not vectorized g.peterhoff@t-online.de
@ 2023-02-23 11:10 ` jakub at gcc dot gnu.org
2023-02-23 17:01 ` [Bug target/108902] " pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-23 11:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108902
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
#include <array>
#include <cstdint>
#include <stdfloat>
#include <algorithm>
#include <execution>
#include <x86intrin.h>
using array_t = std::array<std::float16_t, 128>;
void inc_loop(array_t& arr) noexcept
{
for (auto& val : arr)
++val;
}
void inc_transform(array_t& arr) noexcept
{
std::transform(std::execution::unseq, arr.begin(), arr.end(), arr.begin(),
[](const auto val) constexpr noexcept{return val+1;});
}
void inc_intrinsic(array_t& arr) noexcept
{
auto load_cvt = [](const std::float16_t*const ptr) noexcept
{
return _mm256_cvtph_ps(*((const __m128i*const)ptr));
};
auto save_cvt = [](std::float16_t* ptr, const __m256 arg) noexcept
{
*((__m128i*)ptr) = _mm256_cvtps_ph(arg, _MM_FROUND_CUR_DIRECTION);
};
for (std::size_t i=0; i<arr.size(); i+=8)
{
__m256
tmp = load_cvt(&arr[i]);
++tmp;
save_cvt(&arr[i], tmp);
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/108902] Conversions std::float16_t<->float with FP16C are not vectorized
2023-02-23 11:02 [Bug c++/108902] New: Conversions std::float16_t<->float with FP16C are not vectorized g.peterhoff@t-online.de
2023-02-23 11:10 ` [Bug c++/108902] " jakub at gcc dot gnu.org
@ 2023-02-23 17:01 ` pinskia at gcc dot gnu.org
2023-02-24 5:03 ` crazylht at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-23 17:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108902
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-std=c++23 -march=x86-64-v3 -O3 -mno-vzeroupper
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/108902] Conversions std::float16_t<->float with FP16C are not vectorized
2023-02-23 11:02 [Bug c++/108902] New: Conversions std::float16_t<->float with FP16C are not vectorized g.peterhoff@t-online.de
2023-02-23 11:10 ` [Bug c++/108902] " jakub at gcc dot gnu.org
2023-02-23 17:01 ` [Bug target/108902] " pinskia at gcc dot gnu.org
@ 2023-02-24 5:03 ` crazylht at gmail dot com
2023-02-24 6:13 ` crazylht at gmail dot com
2023-02-24 7:16 ` g.peterhoff@t-online.de
4 siblings, 0 replies; 6+ messages in thread
From: crazylht at gmail dot com @ 2023-02-24 5:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108902
Hongtao.liu <crazylht at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |crazylht at gmail dot com
--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
Yes, in sse.md the corresponding expanders are only defined under
TARGET_AVX512FP16.
7275(define_expand "extend<ssePHmodelower><mode>2"
7276 [(set (match_operand:VF48H_AVX512VL 0 "register_operand")
7277 (float_extend:VF48H_AVX512VL
7278 (match_operand:<ssePHmode> 1 "nonimmediate_operand")))]
7279 "TARGET_AVX512FP16")
7369(define_expand "trunc<mode><ssePHmodelower>2"
7370 [(set (match_operand:<ssePHmode> 0 "register_operand")
7371 (float_truncate:<ssePHmode>
7372 (match_operand:VF48H_AVX512VL 1 "nonimmediate_operand")))]
7373 "TARGET_AVX512FP16")
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/108902] Conversions std::float16_t<->float with FP16C are not vectorized
2023-02-23 11:02 [Bug c++/108902] New: Conversions std::float16_t<->float with FP16C are not vectorized g.peterhoff@t-online.de
` (2 preceding siblings ...)
2023-02-24 5:03 ` crazylht at gmail dot com
@ 2023-02-24 6:13 ` crazylht at gmail dot com
2023-02-24 7:16 ` g.peterhoff@t-online.de
4 siblings, 0 replies; 6+ messages in thread
From: crazylht at gmail dot com @ 2023-02-24 6:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108902
--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Hongtao.liu from comment #3)
> Yes, in sse.md the corresponding expanders are only defined under
> TARGET_AVX512FP16.
Even w/ -mavx512fp16, it's still not vectorized since it relied on
vec_unpacks_hi/lo_v*hf for loop vectorizer. BB vectorizer seems ok.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/108902] Conversions std::float16_t<->float with FP16C are not vectorized
2023-02-23 11:02 [Bug c++/108902] New: Conversions std::float16_t<->float with FP16C are not vectorized g.peterhoff@t-online.de
` (3 preceding siblings ...)
2023-02-24 6:13 ` crazylht at gmail dot com
@ 2023-02-24 7:16 ` g.peterhoff@t-online.de
4 siblings, 0 replies; 6+ messages in thread
From: g.peterhoff@t-online.de @ 2023-02-24 7:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108902
--- Comment #5 from g.peterhoff@t-online.de ---
add test case (https://godbolt.org/z/q65cWKhWx)
void inc_builtin(array_t& arr) noexcept
{
auto load_cvt = [](const std::float16_t*const ptr) noexcept
{
return __builtin_convertvector(*((const __m128h*const)ptr), __m256);
};
auto save_cvt = [](std::float16_t* ptr, const __m256 arg) noexcept
{
*((__m128h*)ptr) = __builtin_convertvector(arg, __m128h);
};
for (std::size_t i=0; i<arr.size(); i+=8)
{
__m256
tmp = load_cvt(&arr[i]);
++tmp;
save_cvt(&arr[i], tmp);
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-24 7:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23 11:02 [Bug c++/108902] New: Conversions std::float16_t<->float with FP16C are not vectorized g.peterhoff@t-online.de
2023-02-23 11:10 ` [Bug c++/108902] " jakub at gcc dot gnu.org
2023-02-23 17:01 ` [Bug target/108902] " pinskia at gcc dot gnu.org
2023-02-24 5:03 ` crazylht at gmail dot com
2023-02-24 6:13 ` crazylht at gmail dot com
2023-02-24 7:16 ` g.peterhoff@t-online.de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).