From 75d2444b6476ba228b4dcc703021ed8188deb4dc Mon Sep 17 00:00:00 2001 From: mwish Date: Sun, 25 Oct 2026 19:04:43 +0800 Subject: [PATCH] Optimize ALP Decompress in clang --- cpp/src/arrow/util/alp/alp_compression.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpp/src/arrow/util/alp/alp_compression.cc b/cpp/src/arrow/util/alp/alp_compression.cc index 6b40f4e39a9f..73028091f287 100644 --- a/cpp/src/arrow/util/alp/alp_compression.cc +++ b/cpp/src/arrow/util/alp/alp_compression.cc @@ -561,10 +561,13 @@ void AlpCompression::Decompress(const AlpEncodedVectorView& encoded_view, // Fused unFOR + decode loop: undo FOR in unsigned arithmetic, reinterpret the // result as signed encoded integers, then apply the normative decimal decode. const EncodedUnsigned frame_of_ref = for_info.frame_of_reference(); + // Read the exponent/factor once. AlpInfo stores them as uint8_t, which may + // alias the output stores, so reading them inside the loop blocks vectorization. + const AlpExponentAndFactor exponent_and_factor = alp_info.GetExponentAndFactor(); for (size_t i = 0; i < output.size(); ++i) { const EncodedUnsigned unfored_value = scratch[i] + frame_of_ref; const EncodedSigned signed_value = util::SafeCopy(unfored_value); - output[i] = AlpInlines::DecodeValue(signed_value, alp_info.GetExponentAndFactor()); + output[i] = AlpInlines::DecodeValue(signed_value, exponent_and_factor); } PatchExceptions(