public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/105593] New: avx512 math function raises uninitialized variable warning
@ 2022-05-13 14:35 rogerio.souza at gmail dot com
  2022-05-13 14:42 ` [Bug target/105593] " pinskia at gcc dot gnu.org
                   ` (32 more replies)
  0 siblings, 33 replies; 34+ messages in thread
From: rogerio.souza at gmail dot com @ 2022-05-13 14:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

            Bug ID: 105593
           Summary: avx512 math function raises uninitialized variable
                    warning
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rogerio.souza at gmail dot com
  Target Milestone: ---

When using avx512 math function we got the following warning:

/<gcc_path>/lib/gcc/x86_64-redhat-linux/12.1.0/include/avx512fintrin.h:6994:10:
error: '__Y' may be used uninitialized [-Werror=maybe-uninitialized]

The code that triggers the error is the one below, from file avx512fintrin.h:

  202 extern __inline __m512i
  203 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
  204 _mm512_undefined_epi32 (void)
  205 {
  206   __m512i __Y = __Y; // Uninitialized variable "__Y"
  207   return __Y;
  208 }

Should this code be reviewed?

Using "-Wno-uninitialized" prevents this warning from happening.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug target/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
@ 2022-05-13 14:42 ` pinskia at gcc dot gnu.org
  2022-05-13 14:43 ` pinskia at gcc dot gnu.org
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-13 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|other                       |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>Should this code be reviewed?

This is exactly what this function does.
Can you provide the exact command line and the preprocessed file that you are
hitting the warning from?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug target/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
  2022-05-13 14:42 ` [Bug target/105593] " pinskia at gcc dot gnu.org
@ 2022-05-13 14:43 ` pinskia at gcc dot gnu.org
  2022-05-13 16:58 ` rogerio.souza at gmail dot com
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-13 14:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |X86_64
   Last reconfirmed|                            |2022-05-13
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug target/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
  2022-05-13 14:42 ` [Bug target/105593] " pinskia at gcc dot gnu.org
  2022-05-13 14:43 ` pinskia at gcc dot gnu.org
@ 2022-05-13 16:58 ` rogerio.souza at gmail dot com
  2022-05-13 17:04 ` rogerio.souza at gmail dot com
                   ` (29 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: rogerio.souza at gmail dot com @ 2022-05-13 16:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #2 from Rogério de Souza Moraes <rogerio.souza at gmail dot com> ---
Created attachment 52971
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52971&action=edit
C code to trigger the uninitialized warning

The C code attached reproduces the uninitialized warning when compiled with
-O3.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug target/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (2 preceding siblings ...)
  2022-05-13 16:58 ` rogerio.souza at gmail dot com
@ 2022-05-13 17:04 ` rogerio.souza at gmail dot com
  2022-05-16  7:16 ` [Bug c++/105593] [12/13 Regression] " rguenth at gcc dot gnu.org
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: rogerio.souza at gmail dot com @ 2022-05-13 17:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #3 from Rogério de Souza Moraes <rogerio.souza at gmail dot com> ---
The code attached in the previous comment triggers the "warning: '__Y' is used
uninitialized [-Wuninitialized]".

The command line to compile it is:

/grid/common/test/gcc-v12.1.0d1rh74_lnx86/bin/gcc -c -O3 -Wall ./a.C

Using "-O1/-O2/-O3" the warning below is raised:

In file included from
/grid/common/test/gcc-v12.1.0d1rh74_lnx86/lib/gcc/x86_64-redhat-linux/12.1.0/include/immintrin.h:49,
                 from ./a.C:1:
In function '__m512i _mm512_permutexvar_epi64(__m512i, __m512i)',
    inlined from 'void UINT512_t::ithBit(int)' at ./a.C:12:40,
    inlined from 'WORD_t ithBitWORD(int) [with WORD_t = UINT512_t]' at
./a.C:27:13:
/grid/common/test/gcc-v12.1.0d1rh74_lnx86/lib/gcc/x86_64-redhat-linux/12.1.0/include/avx512fintrin.h:6994:10:
warning: '__Y' is used uninitialized [-Wuninitialized]
 6994 |   return (__m512i) __builtin_ia32_permvardi512_mask ((__v8di) __Y,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 6995 |                                                      (__v8di) __X,
      |                                                      ~~~~~~~~~~~~~
 6996 |                                                      (__v8di)
      |                                                      ~~~~~~~~
 6997 |                                                     
_mm512_undefined_epi32 (),
      |                                                     
~~~~~~~~~~~~~~~~~~~~~~~~~~
 6998 |                                                      (__mmask8) -1);
      |                                                      ~~~~~~~~~~~~~~
/grid/common/test/gcc-v12.1.0d1rh74_lnx86/lib/gcc/x86_64-redhat-linux/12.1.0/include/avx512fintrin.h:
In function 'WORD_t ithBitWORD(int) [with WORD_t = UINT512_t]':
/grid/common/test/gcc-v12.1.0d1rh74_lnx86/lib/gcc/x86_64-redhat-linux/12.1.0/include/avx512fintrin.h:206:11:
note: '__Y' was declared here
  206 |   __m512i __Y = __Y;
      |           ^~~


When compiling with -O0, the warning does not happen, so I believe it is due to
the optimization that probably reduces the assembly code and triggers the
warning. Is it correct? If so, what would be the best approach to suppress it?
Would it be '#pragma GCC diagnostic ignored "-Wuninitialized"'?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] [12/13 Regression] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (3 preceding siblings ...)
  2022-05-13 17:04 ` rogerio.souza at gmail dot com
@ 2022-05-16  7:16 ` rguenth at gcc dot gnu.org
  2022-06-01 19:36 ` [Bug c++/105593] " jason at gcc dot gnu.org
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-16  7:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
           Keywords|                            |diagnostic, needs-bisection
   Target Milestone|---                         |12.2
             Status|WAITING                     |NEW
             Target|X86_64                      |x86_64-*-*
            Summary|avx512 math function raises |[12/13 Regression] avx512
                   |uninitialized variable      |math function raises
                   |warning                     |uninitialized variable
                   |                            |warning
          Component|target                      |c++

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We possibly lose the Wno-uninitialized annotation/suppression of
the variable (during inlining?) somewhere.

Simpler testcase:

extern inline __attribute__((__gnu_inline__,__always_inline__))
int foo ()
{
  int r = r;
  return r;
}

void bar (int);

void baz()
{
  int u = foo ();
  bar (u);
}

fails to hide the -Wuninitialized with the C++ frontend, works correct with the
C frontend and on the GCC 11 branch.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (4 preceding siblings ...)
  2022-05-16  7:16 ` [Bug c++/105593] [12/13 Regression] " rguenth at gcc dot gnu.org
@ 2022-06-01 19:36 ` jason at gcc dot gnu.org
  2022-06-02  6:41 ` rguenth at gcc dot gnu.org
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jason at gcc dot gnu.org @ 2022-06-01 19:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
           Keywords|needs-bisection             |
            Summary|[12/13 Regression] avx512   |avx512 math function raises
                   |math function raises        |uninitialized variable
                   |uninitialized variable      |warning
                   |warning                     |
           Priority|P2                          |P3

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> fails to hide the -Wuninitialized with the C++ frontend, works correct with
> the C frontend and on the GCC 11 branch.

I also get the warning on the 11 branch.  And all the way back to the 4.1
branch, which is the oldest I have handy; this doesn't seem like a regression.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (5 preceding siblings ...)
  2022-06-01 19:36 ` [Bug c++/105593] " jason at gcc dot gnu.org
@ 2022-06-02  6:41 ` rguenth at gcc dot gnu.org
  2022-06-23 16:18 ` rogerio.souza at gmail dot com
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-02  6:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.2                        |---
      Known to fail|                            |4.1.2

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (6 preceding siblings ...)
  2022-06-02  6:41 ` rguenth at gcc dot gnu.org
@ 2022-06-23 16:18 ` rogerio.souza at gmail dot com
  2022-11-22 19:14 ` pinskia at gcc dot gnu.org
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: rogerio.souza at gmail dot com @ 2022-06-23 16:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #6 from Rogério de Souza Moraes <rogerio.souza at gmail dot com> ---
I got another example with similar warning:

#################

#include <iostream>
//#pragma GCC diagnostic push
//#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#include <regex>
//#pragma GCC diagnostic pop
#include <string>

namespace sysOs
{
  std::regex rgxVer("ABC");
}

int main()
{
  return 0;
}

#######################

The code above is available at https://godbolt.org/z/chsjPKE33. 

Compiled with:

    gcc -c -fPIC -Werror -std=c++2a  -Wno-unused -O -Wall

it returns the warning:

/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/bits/std_function.h:405:42:
error: '*(std::function<bool(char)>*)((char*)&__tmp +
offsetof(std::__detail::_StateT,
std::__detail::_State<char>::<unnamed>.std::__detail::_State_base::<unnamed>)).std::function<bool(char)>::_M_invoker'
may be used uninitialized [-Werror=maybe-uninitialized]
  405 |       : _Function_base(), _M_invoker(__x._M_invoker)
      |                                      ~~~~^~~~~~~~~~


Would it be related with the same issue reported here? This example does not
raise the warning on GCC 11.3.

Regards,
--
Rogerio

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (7 preceding siblings ...)
  2022-06-23 16:18 ` rogerio.souza at gmail dot com
@ 2022-11-22 19:14 ` pinskia at gcc dot gnu.org
  2023-01-12  8:09 ` rguenth at gcc dot gnu.org
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-22 19:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bill.trost at harmonicinc dot com

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 107825 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (8 preceding siblings ...)
  2022-11-22 19:14 ` pinskia at gcc dot gnu.org
@ 2023-01-12  8:09 ` rguenth at gcc dot gnu.org
  2023-01-12 11:44 ` jay+ggcc@jp-hosting.net
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-12  8:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #5)
> (In reply to Richard Biener from comment #4)
> > fails to hide the -Wuninitialized with the C++ frontend, works correct with
> > the C frontend and on the GCC 11 branch.
> 
> I also get the warning on the 11 branch.  And all the way back to the 4.1
> branch, which is the oldest I have handy; this doesn't seem like a
> regression.

I can confirm that even

void bar (int);

void baz()
{
  int u = u;
  bar (u);
}

warns with the C++ frontend, so the self-init "trick" to suppress uninit
diagnostics was never implemented in the new parser (it diagnoses with
GCC 3.4 but not with 3.3).  So it's kind-of a regression, but ...

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (9 preceding siblings ...)
  2023-01-12  8:09 ` rguenth at gcc dot gnu.org
@ 2023-01-12 11:44 ` jay+ggcc@jp-hosting.net
  2023-01-12 14:03 ` jakub at gcc dot gnu.org
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jay+ggcc@jp-hosting.net @ 2023-01-12 11:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

James Addison <jay+ggcc@jp-hosting.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jay+ggcc@jp-hosting.net

--- Comment #9 from James Addison <jay+ggcc@jp-hosting.net> ---
A similar warning is raised when compiling avx512erintrin.h with optimization
and -Wuninitialized enabled:

    /usr/lib/gcc/x86_64-linux-gnu/12/include/avx512erintrin.h:55:20: warning:
‘__W’ is used uninitialized [-Wuninitialized]

The relevant GCC code can be found at
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/avx512erintrin.h;h=6b3b679a17675612f45a1090f227012b80b871a6#l54

The compilation command-line used was: gcc -O -Wuninitialized -mavx512er
-mavx512pf

The code-under-compilation can be found at
https://github.com/numpy/numpy/blob/bb2769e12a8646f3d63097e9464592aa6e20058d/numpy/distutils/checks/cpu_avx512_knl.c

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (10 preceding siblings ...)
  2023-01-12 11:44 ` jay+ggcc@jp-hosting.net
@ 2023-01-12 14:03 ` jakub at gcc dot gnu.org
  2023-01-12 14:26 ` jakub at gcc dot gnu.org
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-12 14:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems the difference between C and C++ is documented:
'-Winit-self (C, C++, Objective-C and Objective-C++ only)'
     Warn about uninitialized variables that are initialized with
     themselves.  Note this option can only be used with the
     '-Wuninitialized' option.

     For example, GCC warns about 'i' being uninitialized in the
     following snippet only when '-Winit-self' has been specified:
          int f()
          {
            int i = i;
            return i;
          }

     This warning is enabled by '-Wall' in C++.

We do emit the warning even in C with -W -Wall -Winit-self, and don't emit
it with -W -Wall -Wno-init-self in C++.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (11 preceding siblings ...)
  2023-01-12 14:03 ` jakub at gcc dot gnu.org
@ 2023-01-12 14:26 ` jakub at gcc dot gnu.org
  2023-01-12 15:10 ` jakub at gcc dot gnu.org
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-12 14:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |redi at gcc dot gnu.org

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This changed with PR53210.  See e.g.
https://gcc.gnu.org/legacy-ml/gcc-patches/2012-09/msg00898.html
Though, not sure how else we could avoid the warning.
void bar (int);

static inline int
baz (void)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#pragma GCC diagnostic ignored "-Winit-self"
  int u = u;
  return u;
#pragma GCC diagnostic pop
}

void
foo (void)
{
  int u = baz ();
  bar (u);
}

certainly doesn't work, what works is to make the -Wuninitialized diagnostic
ignored at the use side, but that is incompatible with how _mm*_undefined*
intrinsics are meant to be used.
Note, the above (in particular the first diagnostic ignored alone) pragma helps
to shut the warning up in clang.  Though, for the intrinsic headers we care
just about gcc.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (12 preceding siblings ...)
  2023-01-12 14:26 ` jakub at gcc dot gnu.org
@ 2023-01-12 15:10 ` jakub at gcc dot gnu.org
  2023-01-16  8:41 ` cvs-commit at gcc dot gnu.org
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-12 15:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54257
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54257&action=edit
gcc13-pr105593.patch

What we could do is test if -Winit-self is enabled at the point we decide if
we should suppress it.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (13 preceding siblings ...)
  2023-01-12 15:10 ` jakub at gcc dot gnu.org
@ 2023-01-16  8:41 ` cvs-commit at gcc dot gnu.org
  2023-01-16  8:42 ` cvs-commit at gcc dot gnu.org
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-16  8:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:98b41fd4045b7856e7b85dd58d67c600bd909379

commit r13-5185-g98b41fd4045b7856e7b85dd58d67c600bd909379
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jan 16 09:40:14 2023 +0100

    c, c++: Allow ignoring -Winit-self through pragmas [PR105593]

    As mentioned in the PR, various x86 intrinsics need to return
    an uninitialized vector.  Currently they use self initialization
    to avoid -Wuninitialized warnings, which works fine in C, but
    doesn't work in C++ where -Winit-self is enabled in -Wall.
    We don't have an attribute to mark a variable as knowingly
    uninitialized (the uninitialized attribute exists but means
    something else, only in the -ftrivial-auto-var-init context),
    and trying to suppress either -Wuninitialized or -Winit-self
    inside of the _mm_undefined_ps etc. intrinsic definitions
    doesn't work, one needs to currently disable through pragmas
    -Wuninitialized warning at the point where _mm_undefined_ps etc.
    result is actually used, but that goes against the intent of
    those intrinsics.

    The -Winit-self warning option actually doesn't do any warning,
    all we do is record a suppression for -Winit-self if !warn_init_self
    on the decl definition and later look that up in uninit pass.

    The following patch changes those !warn_init_self tests which
    are true only based on the command line option setting, not based
    on GCC diagnostic pragma overrides to
    !warning_enabled_at (DECL_SOURCE_LOCATION (decl), OPT_Winit_self)
    such that it takes them into account.

    2023-01-16  Jakub Jelinek  <jakub@redhat.com>

            PR c++/105593
    gcc/c/
            * c-parser.cc (c_parser_initializer): Check warning_enabled_at
            at the DECL_SOURCE_LOCATION (decl) for OPT_Winit_self instead
            of warn_init_self.
    gcc/cp/
            * decl.cc (cp_finish_decl): Check warning_enabled_at
            at the DECL_SOURCE_LOCATION (decl) for OPT_Winit_self instead
            of warn_init_self.
    gcc/testsuite/
            * c-c++-common/Winit-self3.c: New test.
            * c-c++-common/Winit-self4.c: New test.
            * c-c++-common/Winit-self5.c: New test.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (14 preceding siblings ...)
  2023-01-16  8:41 ` cvs-commit at gcc dot gnu.org
@ 2023-01-16  8:42 ` cvs-commit at gcc dot gnu.org
  2023-01-16  9:04 ` jakub at gcc dot gnu.org
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-16  8:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:6b0907b4fc455377e5f8109f427d97da02b6aec9

commit r13-5186-g6b0907b4fc455377e5f8109f427d97da02b6aec9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jan 16 09:41:38 2023 +0100

    x86: Avoid -Wuninitialized warnings on _mm*_undefined_* in C++ [PR105593]

    In https://gcc.gnu.org/pipermail/gcc-patches/2023-January/609844.html
    I've posted a patch to allow ignoring -Winit-self using GCC diagnostic
    pragmas, such that one can mark self-initialization as intentional
    disabling of -Wuninitialized warnings.

    The following incremental patch uses that in the x86 intrinsic
    headers.

    2023-01-16  Jakub Jelinek  <jakub@redhat.com>

            PR c++/105593
    gcc/
            * config/i386/xmmintrin.h (_mm_undefined_ps): Temporarily
            disable -Winit-self using pragma GCC diagnostic ignored.
            * config/i386/emmintrin.h (_mm_undefined_pd, _mm_undefined_si128):
            Likewise.
            * config/i386/avxintrin.h (_mm256_undefined_pd,
_mm256_undefined_ps,
            _mm256_undefined_si256): Likewise.
            * config/i386/avx512fintrin.h (_mm512_undefined_pd,
            _mm512_undefined_ps, _mm512_undefined_epi32): Likewise.
            * config/i386/avx512fp16intrin.h (_mm_undefined_ph,
            _mm256_undefined_ph, _mm512_undefined_ph): Likewise.
    gcc/testsuite/
            * g++.target/i386/pr105593.C: New test.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (15 preceding siblings ...)
  2023-01-16  8:42 ` cvs-commit at gcc dot gnu.org
@ 2023-01-16  9:04 ` jakub at gcc dot gnu.org
  2023-01-29 15:15 ` jay+ggcc@jp-hosting.net
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-16  9:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (16 preceding siblings ...)
  2023-01-16  9:04 ` jakub at gcc dot gnu.org
@ 2023-01-29 15:15 ` jay+ggcc@jp-hosting.net
  2023-01-30 17:46 ` jakub at gcc dot gnu.org
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jay+ggcc@jp-hosting.net @ 2023-01-29 15:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #16 from James Addison <jay+ggcc@jp-hosting.net> ---
Does it make sense to update some of the other variable declarations (like
this[1] one) within optimized blocks to use self-initialization as part of this
bug, or should I create a separate bug for that? (or, an acceptable option
three: no, that's wrong, don't bother)

[1] -
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/avx512erintrin.h;h=7d6aecb70c27579a394360cc82f500acc4519430;hb=HEAD#l54

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (17 preceding siblings ...)
  2023-01-29 15:15 ` jay+ggcc@jp-hosting.net
@ 2023-01-30 17:46 ` jakub at gcc dot gnu.org
  2023-01-31  8:21 ` cvs-commit at gcc dot gnu.org
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-30 17:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to James Addison from comment #16)
> Does it make sense to update some of the other variable declarations (like
> this[1] one) within optimized blocks to use self-initialization as part of
> this bug, or should I create a separate bug for that? (or, an acceptable
> option three: no, that's wrong, don't bother)
> 
> [1] -
> https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/avx512erintrin.h;
> h=7d6aecb70c27579a394360cc82f500acc4519430;hb=HEAD#l54

No, it should instead use _mm512_undefined_ps () etc. instead of those
uninitialized __W etc. variables.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (18 preceding siblings ...)
  2023-01-30 17:46 ` jakub at gcc dot gnu.org
@ 2023-01-31  8:21 ` cvs-commit at gcc dot gnu.org
  2023-01-31 10:53 ` jay+ggcc@jp-hosting.net
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-31  8:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #18 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:41602390456901c14ecdfa2fa64c3cebd5b6ff09

commit r13-5526-g41602390456901c14ecdfa2fa64c3cebd5b6ff09
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jan 31 09:20:34 2023 +0100

    i386: Fix up -Wuninitialized warnings in avx512erintrin.h [PR105593]

    As reported in the PR, there are some -Wuninitialized warnings in
    avx512erintrin.h.  One can see that by compiling sse-23.c testcase with
    -Wuninitialized (or when actually using those intrinsics).
    Those 6 spots use an uninitialized variable and pass it as one of the
    argument to a builtin with constant mask -1, because there is no unmasked
    builtin.  It is true that expansion of those builtins into RTL will see
    mask is all ones and ignore the unneeded argument, but -Wuninitialized
    is diagnosed on GIMPLE and on GIMPLE these builtins are just builtin calls.
    avx512fintrin.h and other headers use in these cases the _mm*_undefined_*
()
    intrinsics, like:
      return (__m512i) __builtin_ia32_psrav8di_mask ((__v8di) __X,
                                                     (__v8di) __Y,
                                                     (__v8di)
                                                     _mm512_undefined_epi32 (),
                                                     (__mmask8) -1);
    etc. and the following patch does the same for avx512erintrin.h.
    With the recent changes in C++ FE and the _mm*_undefined_* intrinsics,
    we don't emit -Wuninitialized warnings for those (previously we didn't
    just in C due to self-initialization).  Of course we could also
    just self-initialize these uninitialized vars and add the #pragma GCC
    diagnostic dances around it, but using the intrinsics is consistent with
    the rest and IMHO cleaner.

    2023-01-31  Jakub Jelinek  <jakub@redhat.com>

            PR c++/105593
            * config/i386/avx512erintrin.h (_mm512_exp2a23_round_pd,
            _mm512_exp2a23_round_ps, _mm512_rcp28_round_pd,
_mm512_rcp28_round_ps,
            _mm512_rsqrt28_round_pd, _mm512_rsqrt28_round_ps): Use
            _mm512_undefined_pd () or _mm512_undefined_ps () instead of using
            uninitialized automatic variable __W.

            * gcc.target/i386/sse-23.c: Add -Wuninitialized to dg-options.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (19 preceding siblings ...)
  2023-01-31  8:21 ` cvs-commit at gcc dot gnu.org
@ 2023-01-31 10:53 ` jay+ggcc@jp-hosting.net
  2023-01-31 11:23 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jay+ggcc@jp-hosting.net @ 2023-01-31 10:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #19 from James Addison <jay+ggcc@jp-hosting.net> ---
Thanks, Jakub!

(I had begun developing a patch locally, but hadn't found all of the six
locations, and learning some of the contributing guidelines was going to take
me a while)

Would adding '-Wuninitialized -Werror=uninitialized' to the dg-options in
'gcc/testsuite/gcc.target/i386/avx-1.c' be possible, with these fixes in place?
(as a regression safety net of sorts)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (20 preceding siblings ...)
  2023-01-31 10:53 ` jay+ggcc@jp-hosting.net
@ 2023-01-31 11:23 ` jakub at gcc dot gnu.org
  2023-01-31 11:30 ` jay+ggcc@jp-hosting.net
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-31 11:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to James Addison from comment #19)
> Would adding '-Wuninitialized -Werror=uninitialized' to the dg-options in
> 'gcc/testsuite/gcc.target/i386/avx-1.c' be possible, with these fixes in
> place? (as a regression safety net of sorts)

I don't see what advantages it would have over -Wuninitialized on sse-23.c.
And, -Werror= isn't really needed, the testing infrastructure will mark as
FAILs any
excess diagnostics which isn't expected or pruned out, not just errors.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (21 preceding siblings ...)
  2023-01-31 11:23 ` jakub at gcc dot gnu.org
@ 2023-01-31 11:30 ` jay+ggcc@jp-hosting.net
  2023-02-10 13:21 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jay+ggcc@jp-hosting.net @ 2023-01-31 11:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #21 from James Addison <jay+ggcc@jp-hosting.net> ---
(In reply to Jakub Jelinek from comment #20)
> (In reply to James Addison from comment #19)
> > Would adding '-Wuninitialized -Werror=uninitialized' to the dg-options in
> > 'gcc/testsuite/gcc.target/i386/avx-1.c' be possible, with these fixes in
> > place? (as a regression safety net of sorts)
> 
> I don't see what advantages it would have over -Wuninitialized on sse-23.c.
> And, -Werror= isn't really needed, the testing infrastructure will mark as
> FAILs any
> excess diagnostics which isn't expected or pruned out, not just errors.

Ok, that makes sense - thanks for the explanations.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (22 preceding siblings ...)
  2023-01-31 11:30 ` jay+ggcc@jp-hosting.net
@ 2023-02-10 13:21 ` jakub at gcc dot gnu.org
  2023-02-10 15:02 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 13:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #22 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In order to backport these changes, we'd need to backport PR102633 changes
first.
Marek, do you think it is ok?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (23 preceding siblings ...)
  2023-02-10 13:21 ` jakub at gcc dot gnu.org
@ 2023-02-10 15:02 ` mpolacek at gcc dot gnu.org
  2023-02-10 15:13 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-10 15:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #23 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'm somewhat uneasy about backporting PR102633, to be honest.  But I could try
and test gcc 12 to see if it causes any problems, if you want me to.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (24 preceding siblings ...)
  2023-02-10 15:02 ` mpolacek at gcc dot gnu.org
@ 2023-02-10 15:13 ` jakub at gcc dot gnu.org
  2023-02-10 15:15 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 15:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #23)
> I'm somewhat uneasy about backporting PR102633, to be honest.  But I could
> try and test gcc 12 to see if it causes any problems, if you want me to.

I think causing more warnings than were emitted before on the release branches
is something we should avoid, but this is the opposite, we used to emit
warnings which shouldn't be emitted and don't do that anymore.
Anyway, I'm afraid without the PR102633 changes I don't know how else to solve
this PR which seems quite important (-Wall warning on anything using
_mm*_undefined*, directly or indirectly).

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (25 preceding siblings ...)
  2023-02-10 15:13 ` jakub at gcc dot gnu.org
@ 2023-02-10 15:15 ` mpolacek at gcc dot gnu.org
  2023-02-10 15:16 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-10 15:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #25 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Okay, let me test the backport then.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (26 preceding siblings ...)
  2023-02-10 15:15 ` mpolacek at gcc dot gnu.org
@ 2023-02-10 15:16 ` jakub at gcc dot gnu.org
  2023-02-10 15:18 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 15:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #26 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #25)
> Okay, let me test the backport then.

Well, I already have 40 backports in my 12 tree, so could add your commit and
the 3 from this PR above it.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (27 preceding siblings ...)
  2023-02-10 15:16 ` jakub at gcc dot gnu.org
@ 2023-02-10 15:18 ` mpolacek at gcc dot gnu.org
  2023-02-10 15:22 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-10 15:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #27 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Ah, I'm not even sure if it applies cleanly but if it does, go ahead.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (28 preceding siblings ...)
  2023-02-10 15:18 ` mpolacek at gcc dot gnu.org
@ 2023-02-10 15:22 ` jakub at gcc dot gnu.org
  2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 15:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #28 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #27)
> Ah, I'm not even sure if it applies cleanly but if it does, go ahead.

It does apply cleanly, and the new c-c++-common/Winit-self1.c FAILs without it
and PASSes with it.
When backporting I do such a smoke test on just the testcases from the PR on
each patch separately and then test everything together.  So, queued now.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (29 preceding siblings ...)
  2023-02-10 15:22 ` jakub at gcc dot gnu.org
@ 2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
  2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
  2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
  32 siblings, 0 replies; 34+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #29 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:732d744e82332e7cc269694197c0df2a3635730f

commit r12-9161-g732d744e82332e7cc269694197c0df2a3635730f
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jan 16 09:40:14 2023 +0100

    c, c++: Allow ignoring -Winit-self through pragmas [PR105593]

    As mentioned in the PR, various x86 intrinsics need to return
    an uninitialized vector.  Currently they use self initialization
    to avoid -Wuninitialized warnings, which works fine in C, but
    doesn't work in C++ where -Winit-self is enabled in -Wall.
    We don't have an attribute to mark a variable as knowingly
    uninitialized (the uninitialized attribute exists but means
    something else, only in the -ftrivial-auto-var-init context),
    and trying to suppress either -Wuninitialized or -Winit-self
    inside of the _mm_undefined_ps etc. intrinsic definitions
    doesn't work, one needs to currently disable through pragmas
    -Wuninitialized warning at the point where _mm_undefined_ps etc.
    result is actually used, but that goes against the intent of
    those intrinsics.

    The -Winit-self warning option actually doesn't do any warning,
    all we do is record a suppression for -Winit-self if !warn_init_self
    on the decl definition and later look that up in uninit pass.

    The following patch changes those !warn_init_self tests which
    are true only based on the command line option setting, not based
    on GCC diagnostic pragma overrides to
    !warning_enabled_at (DECL_SOURCE_LOCATION (decl), OPT_Winit_self)
    such that it takes them into account.

    2023-01-16  Jakub Jelinek  <jakub@redhat.com>

            PR c++/105593
    gcc/c/
            * c-parser.cc (c_parser_initializer): Check warning_enabled_at
            at the DECL_SOURCE_LOCATION (decl) for OPT_Winit_self instead
            of warn_init_self.
    gcc/cp/
            * decl.cc (cp_finish_decl): Check warning_enabled_at
            at the DECL_SOURCE_LOCATION (decl) for OPT_Winit_self instead
            of warn_init_self.
    gcc/testsuite/
            * c-c++-common/Winit-self3.c: New test.
            * c-c++-common/Winit-self4.c: New test.
            * c-c++-common/Winit-self5.c: New test.

    (cherry picked from commit 98b41fd4045b7856e7b85dd58d67c600bd909379)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (30 preceding siblings ...)
  2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
@ 2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
  2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
  32 siblings, 0 replies; 34+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #30 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:72af61b122127b112215d496d65c64cfdc56fce8

commit r12-9162-g72af61b122127b112215d496d65c64cfdc56fce8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jan 16 09:41:38 2023 +0100

    x86: Avoid -Wuninitialized warnings on _mm*_undefined_* in C++ [PR105593]

    In https://gcc.gnu.org/pipermail/gcc-patches/2023-January/609844.html
    I've posted a patch to allow ignoring -Winit-self using GCC diagnostic
    pragmas, such that one can mark self-initialization as intentional
    disabling of -Wuninitialized warnings.

    The following incremental patch uses that in the x86 intrinsic
    headers.

    2023-01-16  Jakub Jelinek  <jakub@redhat.com>

            PR c++/105593
    gcc/
            * config/i386/xmmintrin.h (_mm_undefined_ps): Temporarily
            disable -Winit-self using pragma GCC diagnostic ignored.
            * config/i386/emmintrin.h (_mm_undefined_pd, _mm_undefined_si128):
            Likewise.
            * config/i386/avxintrin.h (_mm256_undefined_pd,
_mm256_undefined_ps,
            _mm256_undefined_si256): Likewise.
            * config/i386/avx512fintrin.h (_mm512_undefined_pd,
            _mm512_undefined_ps, _mm512_undefined_epi32): Likewise.
            * config/i386/avx512fp16intrin.h (_mm_undefined_ph,
            _mm256_undefined_ph, _mm512_undefined_ph): Likewise.
    gcc/testsuite/
            * g++.target/i386/pr105593.C: New test.

    (cherry picked from commit 6b0907b4fc455377e5f8109f427d97da02b6aec9)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Bug c++/105593] avx512 math function raises uninitialized variable warning
  2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
                   ` (31 preceding siblings ...)
  2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
@ 2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
  32 siblings, 0 replies; 34+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593

--- Comment #31 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:c3ba6680492ee1ddef6ae8493787c36c45c2d20e

commit r12-9163-gc3ba6680492ee1ddef6ae8493787c36c45c2d20e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jan 31 09:20:34 2023 +0100

    i386: Fix up -Wuninitialized warnings in avx512erintrin.h [PR105593]

    As reported in the PR, there are some -Wuninitialized warnings in
    avx512erintrin.h.  One can see that by compiling sse-23.c testcase with
    -Wuninitialized (or when actually using those intrinsics).
    Those 6 spots use an uninitialized variable and pass it as one of the
    argument to a builtin with constant mask -1, because there is no unmasked
    builtin.  It is true that expansion of those builtins into RTL will see
    mask is all ones and ignore the unneeded argument, but -Wuninitialized
    is diagnosed on GIMPLE and on GIMPLE these builtins are just builtin calls.
    avx512fintrin.h and other headers use in these cases the _mm*_undefined_*
()
    intrinsics, like:
      return (__m512i) __builtin_ia32_psrav8di_mask ((__v8di) __X,
                                                     (__v8di) __Y,
                                                     (__v8di)
                                                     _mm512_undefined_epi32 (),
                                                     (__mmask8) -1);
    etc. and the following patch does the same for avx512erintrin.h.
    With the recent changes in C++ FE and the _mm*_undefined_* intrinsics,
    we don't emit -Wuninitialized warnings for those (previously we didn't
    just in C due to self-initialization).  Of course we could also
    just self-initialize these uninitialized vars and add the #pragma GCC
    diagnostic dances around it, but using the intrinsics is consistent with
    the rest and IMHO cleaner.

    2023-01-31  Jakub Jelinek  <jakub@redhat.com>

            PR c++/105593
            * config/i386/avx512erintrin.h (_mm512_exp2a23_round_pd,
            _mm512_exp2a23_round_ps, _mm512_rcp28_round_pd,
_mm512_rcp28_round_ps,
            _mm512_rsqrt28_round_pd, _mm512_rsqrt28_round_ps): Use
            _mm512_undefined_pd () or _mm512_undefined_ps () instead of using
            uninitialized automatic variable __W.

            * gcc.target/i386/sse-23.c: Add -Wuninitialized to dg-options.

    (cherry picked from commit 41602390456901c14ecdfa2fa64c3cebd5b6ff09)

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2023-02-10 17:47 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 14:35 [Bug other/105593] New: avx512 math function raises uninitialized variable warning rogerio.souza at gmail dot com
2022-05-13 14:42 ` [Bug target/105593] " pinskia at gcc dot gnu.org
2022-05-13 14:43 ` pinskia at gcc dot gnu.org
2022-05-13 16:58 ` rogerio.souza at gmail dot com
2022-05-13 17:04 ` rogerio.souza at gmail dot com
2022-05-16  7:16 ` [Bug c++/105593] [12/13 Regression] " rguenth at gcc dot gnu.org
2022-06-01 19:36 ` [Bug c++/105593] " jason at gcc dot gnu.org
2022-06-02  6:41 ` rguenth at gcc dot gnu.org
2022-06-23 16:18 ` rogerio.souza at gmail dot com
2022-11-22 19:14 ` pinskia at gcc dot gnu.org
2023-01-12  8:09 ` rguenth at gcc dot gnu.org
2023-01-12 11:44 ` jay+ggcc@jp-hosting.net
2023-01-12 14:03 ` jakub at gcc dot gnu.org
2023-01-12 14:26 ` jakub at gcc dot gnu.org
2023-01-12 15:10 ` jakub at gcc dot gnu.org
2023-01-16  8:41 ` cvs-commit at gcc dot gnu.org
2023-01-16  8:42 ` cvs-commit at gcc dot gnu.org
2023-01-16  9:04 ` jakub at gcc dot gnu.org
2023-01-29 15:15 ` jay+ggcc@jp-hosting.net
2023-01-30 17:46 ` jakub at gcc dot gnu.org
2023-01-31  8:21 ` cvs-commit at gcc dot gnu.org
2023-01-31 10:53 ` jay+ggcc@jp-hosting.net
2023-01-31 11:23 ` jakub at gcc dot gnu.org
2023-01-31 11:30 ` jay+ggcc@jp-hosting.net
2023-02-10 13:21 ` jakub at gcc dot gnu.org
2023-02-10 15:02 ` mpolacek at gcc dot gnu.org
2023-02-10 15:13 ` jakub at gcc dot gnu.org
2023-02-10 15:15 ` mpolacek at gcc dot gnu.org
2023-02-10 15:16 ` jakub at gcc dot gnu.org
2023-02-10 15:18 ` mpolacek at gcc dot gnu.org
2023-02-10 15:22 ` jakub at gcc dot gnu.org
2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org

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).