[BugFix] Fix infinite loop when inserting decimal256 data on ARM platforms (backport #63406) (#63434)

Signed-off-by: stephen <stephen5217@163.com>
Co-authored-by: stephen <91597003+stephen-shelby@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2025-09-23 07:47:31 +00:00 committed by GitHub
parent c8582133dd
commit bd6623501f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 18 deletions

View File

@ -83,16 +83,22 @@ struct SIMDGather {
static constexpr uint32_t SIMD_WIDTH = simd_register_bitwidth();
static constexpr uint32_t NUM_BATCH_VALUES = SIMD_WIDTH / (8 * sizeof(DataType));
DataType buffer[NUM_BATCH_VALUES];
size_t i = 0;
for (; i + NUM_BATCH_VALUES <= num_rows; i += NUM_BATCH_VALUES) {
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
buffer[j] = src[indexes[i + j]];
}
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
dest[i + j] = buffer[j];
// Skip batch processing when NUM_BATCH_VALUES = 0 to avoid infinite loop
// This happens for large data types (e.g., int256_t) on small SIMD registers (e.g., ARM NEON 128-bit)
if constexpr (NUM_BATCH_VALUES > 0) {
DataType buffer[NUM_BATCH_VALUES];
for (; i + NUM_BATCH_VALUES <= num_rows; i += NUM_BATCH_VALUES) {
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
buffer[j] = src[indexes[i + j]];
}
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
dest[i + j] = buffer[j];
}
}
}
@ -109,20 +115,26 @@ struct SIMDGather {
static constexpr uint32_t SIMD_WIDTH = simd_register_bitwidth();
static constexpr uint32_t NUM_BATCH_VALUES = SIMD_WIDTH / (8 * sizeof(DataType));
DataType buffer[NUM_BATCH_VALUES];
size_t i = 0;
for (; i + NUM_BATCH_VALUES <= num_rows; i += NUM_BATCH_VALUES) {
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
if (is_filtered[i + j] == 0) {
buffer[j] = src[indexes[i + j]];
} else {
buffer[j] = 0;
}
}
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
dest[i + j] = buffer[j];
// Skip batch processing when NUM_BATCH_VALUES = 0 to avoid infinite loop
// This happens for large data types (e.g., int256_t) on small SIMD registers (e.g., ARM NEON 128-bit)
if constexpr (NUM_BATCH_VALUES > 0) {
DataType buffer[NUM_BATCH_VALUES];
for (; i + NUM_BATCH_VALUES <= num_rows; i += NUM_BATCH_VALUES) {
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
if (is_filtered[i + j] == 0) {
buffer[j] = src[indexes[i + j]];
} else {
buffer[j] = 0;
}
}
for (int j = 0; j < NUM_BATCH_VALUES; j++) {
dest[i + j] = buffer[j];
}
}
}