Skip to content
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

#pragma GCC unroll 0 not allowed: invalid value '0'; must be positive #88624

Closed
MonsterDruide1 opened this issue Apr 13, 2024 · 5 comments · Fixed by #88666
Closed

#pragma GCC unroll 0 not allowed: invalid value '0'; must be positive #88624

MonsterDruide1 opened this issue Apr 13, 2024 · 5 comments · Fixed by #88666
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" extension:gnu

Comments

@MonsterDruide1
Copy link

MonsterDruide1 commented Apr 13, 2024

#pragma GCC unroll 0 does not compile, as apparently the specified number needs to be positive.

/app/main.cpp:4:24: error: invalid value '0'; must be positive
    4 |     #pragma GCC unroll 0
      |                        ^
1 error generated.

However, from https://gcc.gnu.org/onlinedocs/gcc/Loop-Specific-Pragmas.html:

The values of 0 and 1 block any unrolling of the loop.

The program also successfully compiles with GCC, only clang seems to have this implemented incorrectly.

Godbolt: https://godbolt.org/z/bEPo64GsP

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" extension:gnu and removed new issue labels Apr 13, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 13, 2024

@llvm/issue-subscribers-clang-frontend

Author: None (MonsterDruide1)

`#pragma GCC unroll 0` does not compile, as apparently the specified number needs to be positive.
/app/main.cpp:4:24: error: invalid value '0'; must be positive
    4 |     #pragma GCC unroll 0
      |                        ^
1 error generated.

However, from <https://gcc.gnu.org/onlinedocs/gcc/Loop-Specific-Pragmas.html>:
> The values of 0 and 1 block any unrolling of the loop.

The program also successfully compiles with GCC, only clang seems to have this implemented incorrectly.

Godbolt: https://godbolt.org/z/bEPo64GsP

@MonsterDruide1
Copy link
Author

Additional info from discussion on Discord:

@shafik
Copy link
Collaborator

shafik commented Apr 14, 2024

If we look at c724a83 where this change was implemented it looks like the behavior did not change.

@yronglin
Copy link
Contributor

I've a PR to fix this issue #88666 .

@yronglin yronglin self-assigned this Apr 15, 2024
yronglin added a commit that referenced this issue Apr 19, 2024
…roll` and `#pragma unroll` (#88666)

Fixes #88624

GCC allows the value of loop unroll count to be zero, and the values of
0 and 1 block any unrolling of the loop. This PR aims to make clang
keeps the same behavior with GCC.
https://gcc.gnu.org/onlinedocs/gcc/Loop-Specific-Pragmas.html

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
@MonsterDruide1
Copy link
Author

Great, thanks for handling it @yronglin !

searlmc1 pushed a commit to ROCm/llvm-project that referenced this issue Apr 25, 2024
…roll` and `#pragma unroll` (llvm#88666)

Fixes llvm#88624

GCC allows the value of loop unroll count to be zero, and the values of
0 and 1 block any unrolling of the loop. This PR aims to make clang
keeps the same behavior with GCC.
https://gcc.gnu.org/onlinedocs/gcc/Loop-Specific-Pragmas.html

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
Change-Id: I7974f28337c270c8239f0e24ea16c09bc3c21c80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" extension:gnu
Projects
None yet
5 participants