-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[clang] constexpr built-in reduce add function. #116243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -723,3 +723,9 @@ not within the bounds of the input vectors; index of -1 found at position 0 is n | |
| permitted in a constexpr context}} | ||
| vector4charConst1, | ||
| vector4charConst2, -1, -1, -1, -1); | ||
|
|
||
| static_assert(__builtin_reduce_add((vector4char){}) == 0); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this handled? I'd have expected
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is similar to zero initializing a vector with 4 char elements. |
||
| static_assert(__builtin_reduce_add((vector4char){1, 2, 3, 4}) == 10); | ||
| static_assert(__builtin_reduce_add((vector4short){10, 20, 30, 40}) == 100); | ||
| static_assert(__builtin_reduce_add((vector4int){100, 200, 300, 400}) == 1000); | ||
| static_assert(__builtin_reduce_add((vector4long){1000, 2000, 3000, 4000}) == 10000); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(style) Avoid auto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.