[UnitTests] Add initial set of tests with multiple early exits.#325
Merged
Conversation
Member
|
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. |
93608f8 to
5bb9dbc
Compare
fhahn
commented
Jan 20, 2026
fhahn
left a comment
Contributor
Author
There was a problem hiding this comment.
Rebased and simplified a bit
Meinersbur
reviewed
Jan 22, 2026
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;); |
Member
There was a problem hiding this comment.
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;
});
Contributor
Author
There was a problem hiding this comment.
Unfortunately the for loop must be directly passed, otherwise the loop pragmas cannot be applied.
| #include <stdint.h> | ||
|
|
||
| #define N 512 | ||
| // N_ODD is not divisible by common VFs (4, 8, 16) to test scalar epilogue. |
Member
There was a problem hiding this comment.
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. |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
It it is worth extracting out the constant, also give it a description of where it is used?
5bb9dbc to
8babfa6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend the single-early exits tests (#264) to also test loops with multiple exits.
Depends on #264 (included in PR)