Skip to content

Commit

Permalink
Change loop counter to unsigned to fix a spurious gcc-13 warning (#7314)
Browse files Browse the repository at this point in the history
It seems to think that the row counter somehow can have any negative
value, but I couldn't find a way for that to happen.
  • Loading branch information
akuzm authored Oct 1, 2024
1 parent ddeb071 commit e4d909c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tsl/src/nodes/vector_agg/function/float48_accum_single.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ FUNCTION_NAME(combine)(double *inout_N, double *inout_Sx,
#endif

static pg_attribute_always_inline void
FUNCTION_NAME(vector_impl)(void *agg_state, int n, const CTYPE *values, const uint64 *valid1,
FUNCTION_NAME(vector_impl)(void *agg_state, size_t n, const CTYPE *values, const uint64 *valid1,
const uint64 *valid2, MemoryContext agg_extra_mctx)
{
/*
Expand All @@ -212,15 +212,15 @@ FUNCTION_NAME(vector_impl)(void *agg_state, int n, const CTYPE *values, const ui
double Sxxarray[UNROLL_SIZE] = { 0 };
#endif

int row = 0;
size_t row = 0;

#ifdef NEED_SXX
/*
* Initialize each state with the first matching row. We do this separately
* to make the actual update function branchless, namely the computation of
* Sxx which works differently for the first row.
*/
for (int inner = 0; inner < UNROLL_SIZE; inner++)
for (size_t inner = 0; inner < UNROLL_SIZE; inner++)
{
for (; row < n; row++)
{
Expand All @@ -240,7 +240,8 @@ FUNCTION_NAME(vector_impl)(void *agg_state, int n, const CTYPE *values, const ui
* Scroll to the row that is a multiple of UNROLL_SIZE. This is the correct
* row at which to enter the unrolled loop below.
*/
for (int inner = row % UNROLL_SIZE; inner > 0 && inner < UNROLL_SIZE && row < n; inner++, row++)
for (size_t inner = row % UNROLL_SIZE; inner > 0 && inner < UNROLL_SIZE && row < n;
inner++, row++)
{
UPDATE(valid1, valid2, values, row, &Narray[inner], &Sxarray[inner], &Sxxarray[inner]);
}
Expand All @@ -252,7 +253,7 @@ FUNCTION_NAME(vector_impl)(void *agg_state, int n, const CTYPE *values, const ui
Assert(row % UNROLL_SIZE == 0 || row == n);
for (; row < UNROLL_SIZE * (n / UNROLL_SIZE); row += UNROLL_SIZE)
{
for (int inner = 0; inner < UNROLL_SIZE; inner++)
for (size_t inner = 0; inner < UNROLL_SIZE; inner++)
{
UPDATE(valid1,
valid2,
Expand All @@ -269,7 +270,7 @@ FUNCTION_NAME(vector_impl)(void *agg_state, int n, const CTYPE *values, const ui
*/
for (; row < n; row++)
{
const int inner = row % UNROLL_SIZE;
const size_t inner = row % UNROLL_SIZE;
UPDATE(valid1, valid2, values, row, &Narray[inner], &Sxarray[inner], &Sxxarray[inner]);
}

Expand Down

0 comments on commit e4d909c

Please sign in to comment.