On 13/10/2026 06:24, Junwang Zhao wrote:
On Sun, Oct 11, 2026 at 12:16 AM zengxx <[email protected]> wrote:
While looking at wide numeric aggregates, I found that the digit
accumulation loop in accum_sum_add() did not auto-vectorize.  It advances
two indexes together:

     for (val_i = 0; val_i < val_ndigits; val_i++)
     {
         accum_digits[i] += (int32) val_digits[val_i];
         i++;
     }

The attached patch advances the destination pointer once before the loop:

     accum_digits += accum->weight - val->weight;
     for (val_i = 0; val_i < val_ndigits; val_i++)
         accum_digits[val_i] += (int32) val_digits[val_i];

One small nit, could we use i instead of val_i and declare it directly in the
for loop, which seems like a modern coding style accepted by postgres.

Committed with that little change, thanks.

- Heikki



Reply via email to