Bug 107283 - conversions u/int64_t to float64/32_t are not vectorized
Summary: conversions u/int64_t to float64/32_t are not vectorized
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 13.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: vectorizer
  Show dependency treegraph
 
Reported: 2022-10-16 23:22 UTC by Gero
Modified: 2023-02-15 20:30 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-*-* i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-10-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gero 2022-10-16 23:22:14 UTC
The conversions u/int64_t to float64/32_t are not vectorisized if no HW-support (eg AVX512) available.

But we can do that manually
https://stackoverflow.com/questions/41144668/how-to-efficiently-perform-double-int64-conversions-with-sse-avx

In the case u/int64_t -> float32_t i first convert to float64_t and then to float32_t. There might be a better way to implement this.

With HW-support the standard implementation is of course faster.

https://godbolt.org/z/WTa663PrK

thx
Gero
Comment 1 Andrew Pinski 2022-10-16 23:24:29 UTC
I suspect there is a dup of this bug already.
Comment 2 Gero 2022-10-16 23:31:56 UTC
That will be right. I had reported something similar many years ago - but it was not fixed.

thx
Gero
Comment 3 Richard Biener 2022-10-17 08:10:51 UTC
More like a target issue.  Note that u/int64_t when it doesn't fit float32_t
eventually would need to raise a different exception than the float64_t -> float32_t Inf result does so the trick might not be fully IEEE conforming.
Comment 4 Jakub Jelinek 2022-10-17 09:41:28 UTC
The link you've provided is about how to do it with severe limitations.
So, we could do it that way only if the ranger tells us the integral (or floating point) values are in a certain range (+ -ffast-math or similar that you don't care about infinities etc.).
Comment 5 Jakub Jelinek 2022-10-17 09:59:06 UTC
Sorry, I missed the full sequences later on for {,u}int64_t -> double, that is something to look at first I guess.