Repository navigation
Add support and proper relocation of GCC loop pragmas [GH #174] #201
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
Merged
+870
−3,259
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| //allowed_words: novector | ||
| [GH #174] | ||
| C- and C++-generating back ends: placement of GCC loop pragmas | ||
|
|
||
| The GCC loop pragmas "#pragma GCC unroll", "#pragma GCC ivdep", and | ||
| "#pragma GCC novector" were previously recorded in the IL as pragmas of the | ||
| enclosing block and so were emitted by the C-generating back end at the start | ||
| of that block, rather than immediately in front of the loop to which they | ||
| apply. The back-end compiler then rejected the generated code. For example: | ||
|
|
||
| void h(); | ||
| void f(char *first, char *last) { | ||
| h(); | ||
| #pragma GCC unroll 4 // Previously emitted in front of the call of h, | ||
| while (first != last) // causing a "for, while or do statement expected" | ||
| ++first; // error from the back-end compiler. | ||
| } | ||
|
|
||
| In C99 and later modes, the C++-generating back end emitted such a pragma in | ||
| front of the implicit block that surrounds an iteration statement, rather than | ||
| in front of the loop inside it. A loop pragma that followed an iteration or | ||
| selection statement was emitted inside that statement's implicit block. In | ||
| both cases, the generated code could not be compiled. | ||
|
|
||
| When the loop has attributes (e.g., "[[likely]]"), the C++-generating back | ||
| end now emits the loop pragmas after those attributes when the generated code | ||
| is for GCC, which requires a loop pragma to immediately precede the loop | ||
| keyword, and before them when it is for Clang, which requires that order. | ||
|
|
||
| The argument of "#pragma GCC unroll" is now scanned and evaluated as an | ||
| integral constant expression, and its value replaces the original text in the | ||
| generated code. Previously, the argument was copied unchanged, so one that | ||
| used C++ constructs or template parameters made the generated C code invalid. | ||
| For example: | ||
|
|
||
| template<int N> void g(int *p) { | ||
| #pragma GCC unroll(N) // Now emitted as "unroll 4" in g<4>. | ||
| for (int i = 0; i < N; ++i) p[i] = 0; | ||
| } | ||
| void h(int *p) { | ||
| #pragma GCC unroll sizeof(decltype(0)) // Now emitted as "unroll 4". | ||
| for (int i = 0; i < 4; ++i) p[i] = 0; | ||
| g<4>(p); | ||
| } | ||
|
|
||
| An argument that is negative or not less than 65535 is now diagnosed, as GCC | ||
| does. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.