Repository navigation
Conversation
|
@pitrou I found gcc and x86 decoding ALP can be optimized with this 😅, would you mind take a look? ( clang will not be affected ) |
There was a problem hiding this comment.
🟡 Changes recommended
The header lacks a direct <bit> include for std::bit_cast, causing compilation failures when transitive includes do not provide its declaration, even if SafeCopy is never instantiated.
1 open issue
What changed in this PR
This PR modernizes arrow::util::SafeCopy to use C++20 std::bit_cast, addressing the GCC loop-vectorization barrier described in #55763.
Changes:
- Replaces aligned storage, memory copying, and cleanup with a direct
std::bit_castcall. - Preserves the existing type constraints and return type.
| File | Description |
|---|---|
cpp/src/arrow/util/ubsan.h |
Simplifies SafeCopy to avoid the aligned-storage laundering path. |
Review effort: Balanced
5bd5e64 to
ba16e7c
Compare
|
Hey @mapleFU , nice find! I see the old version went through std::launder, but I'm not sure why that blocks gcc's optimization and not clang's. Would you mind explaining a bit? I'm trying to learn how this works. |
|
You can gothrough the issue, in gcc, the code below prevents from auto vectorization. |

Rationale for this change
See #55763
What changes are included in this PR?
Change
SafeCopyto callstd::bit_cast.Are these changes tested?
Covered by existing.
Are there any user-facing changes?
no
Was AI used for this PR?
PR code and description written by:
Reviewed before submission by: