public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments
@ 2023-06-19 0:03 denis.yaroshevskij at gmail dot com
2023-06-19 0:17 ` [Bug target/110303] Without -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: denis.yaroshevskij at gmail dot com @ 2023-06-19 0:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110303
Bug ID: 110303
Summary: In debug mode, gcc does not force compile time
evaluation for immediate arguments
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: denis.yaroshevskij at gmail dot com
Target Milestone: ---
Minimum example:
The following code
```
#include "immintrin.h"
constexpr int f() { return 0; }
__m128i shuffle(__m128i x) { return _mm_shuffle_epi32(x, f()); }
```
Does not compile in debug
Godbolt: https://godbolt.org/z/x7bfhr4vY
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110303] Without -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile
2023-06-19 0:03 [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments denis.yaroshevskij at gmail dot com
@ 2023-06-19 0:17 ` pinskia at gcc dot gnu.org
2023-06-19 0:19 ` [Bug target/110303] With " pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-19 0:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110303
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|In debug mode, gcc does not |Without -O0,
|force compile time |_mm_shuffle_epi32 with a
|evaluation for immediate |constexpr function argument
|arguments |does not compile
Component|c++ |target
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is correct behavior really.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110303] With -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile
2023-06-19 0:03 [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments denis.yaroshevskij at gmail dot com
2023-06-19 0:17 ` [Bug target/110303] Without -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile pinskia at gcc dot gnu.org
@ 2023-06-19 0:19 ` pinskia at gcc dot gnu.org
2023-06-19 0:25 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-19 0:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110303
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
so _mm_shuffle_epi32 requires a constant but since it is an argument, the
argument, it is not a constant expression requirement.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110303] With -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile
2023-06-19 0:03 [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments denis.yaroshevskij at gmail dot com
2023-06-19 0:17 ` [Bug target/110303] Without -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile pinskia at gcc dot gnu.org
2023-06-19 0:19 ` [Bug target/110303] With " pinskia at gcc dot gnu.org
@ 2023-06-19 0:25 ` pinskia at gcc dot gnu.org
2023-06-19 7:40 ` denis.yaroshevskij at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-19 0:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110303
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 80353. constexpr function does not have to be a full constexpression
in many cases.
*** This bug has been marked as a duplicate of bug 80353 ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110303] With -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile
2023-06-19 0:03 [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments denis.yaroshevskij at gmail dot com
` (2 preceding siblings ...)
2023-06-19 0:25 ` pinskia at gcc dot gnu.org
@ 2023-06-19 7:40 ` denis.yaroshevskij at gmail dot com
2023-06-19 12:30 ` xry111 at gcc dot gnu.org
2023-06-19 12:51 ` m.cencora at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: denis.yaroshevskij at gmail dot com @ 2023-06-19 7:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110303
--- Comment #4 from Denis Yaroshevskiy <denis.yaroshevskij at gmail dot com> ---
> so _mm_shuffle_epi32 requires a constant but since it is an argument, the argument, it is not a constant expression requirement.
The function is marked constexpr. So it can be a constant if you ask it.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110303] With -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile
2023-06-19 0:03 [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments denis.yaroshevskij at gmail dot com
` (3 preceding siblings ...)
2023-06-19 7:40 ` denis.yaroshevskij at gmail dot com
@ 2023-06-19 12:30 ` xry111 at gcc dot gnu.org
2023-06-19 12:51 ` m.cencora at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-06-19 12:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110303
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Denis Yaroshevskiy from comment #4)
> > so _mm_shuffle_epi32 requires a constant but since it is an argument, the argument, it is not a constant expression requirement.
>
> The function is marked constexpr. So it can be a constant if you ask it.
The problem is -O0 means "don't ask it". Constant propagation is an
optimization, but -O0 means don't do optimization.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/110303] With -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile
2023-06-19 0:03 [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments denis.yaroshevskij at gmail dot com
` (4 preceding siblings ...)
2023-06-19 12:30 ` xry111 at gcc dot gnu.org
@ 2023-06-19 12:51 ` m.cencora at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: m.cencora at gmail dot com @ 2023-06-19 12:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110303
m.cencora at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |m.cencora at gmail dot com
--- Comment #6 from m.cencora at gmail dot com ---
(In reply to Denis Yaroshevskiy from comment #4)
> > so _mm_shuffle_epi32 requires a constant but since it is an argument, the argument, it is not a constant expression requirement.
>
> The function is marked constexpr. So it can be a constant if you ask it.
constexpr at function declaration means that it COULD be evaluated in compile
time, but doesn't force it.
To force it either invoke it in a context that requires a compile-time
evaluation (e.g. static_assert, or initializer of constexpr variable), or mark
it as consteval instead.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-06-19 12:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19 0:03 [Bug c++/110303] New: In debug mode, gcc does not force compile time evaluation for immediate arguments denis.yaroshevskij at gmail dot com
2023-06-19 0:17 ` [Bug target/110303] Without -O0, _mm_shuffle_epi32 with a constexpr function argument does not compile pinskia at gcc dot gnu.org
2023-06-19 0:19 ` [Bug target/110303] With " pinskia at gcc dot gnu.org
2023-06-19 0:25 ` pinskia at gcc dot gnu.org
2023-06-19 7:40 ` denis.yaroshevskij at gmail dot com
2023-06-19 12:30 ` xry111 at gcc dot gnu.org
2023-06-19 12:51 ` m.cencora at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).