Skip to content

Conversation

@fhahn
Copy link
Contributor

@fhahn fhahn commented Jan 19, 2026

Extend the single-early exits tests (#264) to also test loops with multiple exits.

Depends on #264 (included in PR)

@Meinersbur
Copy link
Member

Meinersbur commented Jan 19, 2026

I took the initiative to approve #264 even though I am not in the reviewer list since none of the revierer's remarks seem to have been resolved. It will be much easier to review this one when I can see the actual diff.

@fhahn fhahn force-pushed the multiple-early-exit-tests branch from 93608f8 to 5bb9dbc Compare January 20, 2026 11:34
Copy link
Contributor Author

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and simplified a bit

Comment on lines +277 to +282
, A, B, C, for (unsigned I = 0; I < N; I++) {
if (A[I] == 0)
return I;
if (A[I] == B[I])
return I + 1000;
} return -1;);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, A, B, C, for (unsigned I = 0; I < N; I++) {
if (A[I] == 0)
return I;
if (A[I] == B[I])
return I + 1000;
} return -1;);
, A, B, C, { for (unsigned I = 0; I < N; I++) {
if (A[I] == 0)
return I;
if (A[I] == B[I])
return I + 1000;
} return -1;});

braces may help clang-format to format this better as code:

DEFINE_SCALAR_AND_VECTOR_EARLY_EXIT_2(int A[N]; int B[N]; int C[N];, A, B, C, {
  for (unsigned I = 0; I < N; I++) {
    if (A[I] == 0)
      return I;
    if (A[I] == B[I])
      return I + 1000;
  }
  return -1;
});

#include <stdint.h>

#define N 512
// N_ODD is not divisible by common VFs (4, 8, 16) to test scalar epilogue.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// N_ODD is not divisible by common VFs (4, 8, 16) to test scalar epilogue.
/// N_ODD is not divisible by common VFs (4, 8, 16) to test scalar epilogue.

Comment on lines +8 to +9
// N_SMALL is a small trip count divisible by common VFs, allowing the compiler
// to potentially eliminate the scalar remainder loop entirely.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// N_SMALL is a small trip count divisible by common VFs, allowing the compiler
// to potentially eliminate the scalar remainder loop entirely.
/// N_SMALL is a small trip count divisible by common VFs, allowing the compiler
/// to potentially eliminate the scalar remainder loop entirely.

#include <limits>
#include <stdint.h>

#define N 512
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It it is worth extracting out the constant, also give it a description of where it is used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants