public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow
@ 2024-06-10  5:37 collin.funk1 at gmail dot com
  2024-06-10  5:48 ` [Bug target/115409] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: collin.funk1 at gmail dot com @ 2024-06-10  5:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115409
           Summary: avx512 intrinsics trigger -Wshift-overflow
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: collin.funk1 at gmail dot com
  Target Milestone: ---

Created attachment 58396
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58396&action=edit
Patch with proposed fix.

When building GNU Coreutils from master:

In file included from
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/immintrin.h:97,
                 from
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/x86intrin.h:32,
                 from src/cksum_pclmul.c:22:
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16intrin.h:
In function '_mm512_conj_pch':
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16intrin.h:3358:73:
error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32
bits [-Werror=shift-overflow=]
 3358 |   return (__m512h) _mm512_xor_epi32 ((__m512i) __A, _mm512_set1_epi32
(1<<31));
      |                                                                        
^~
In file included from
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/immintrin.h:99:
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:
In function '_mm256_conj_pch':
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:184:80:
error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32
bits [-Werror=shift-overflow=]
  184 |   return (__m256h) _mm256_xor_epi32 ((__m256i) __A,
_mm256_avx512_set1_epi32 (1<<31));
      |                                                                        
       ^~
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:
In function '_mm_conj_pch':
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:212:74:
error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32
bits [-Werror=shift-overflow=]
  212 |   return (__m128h) _mm_xor_epi32 ((__m128i) __A, _mm_avx512_set1_epi32
(1<<31));
      |                                                                        
 ^~

This warning seems correct to me. I'm not very familiar with these functions
but I believe making the 1 unsigned before shifting should fix the issue. I
have attached a patch if you would like to double check it.

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

* [Bug target/115409] avx512 intrinsics trigger -Wshift-overflow
  2024-06-10  5:37 [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow collin.funk1 at gmail dot com
@ 2024-06-10  5:48 ` pinskia at gcc dot gnu.org
  2024-06-10  5:50 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-10  5:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-06-10
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

Note patches should be sent to gcc-patches@ after reading
https://gcc.gnu.org/contribute.html .

Also the warning only happens if you use -Wshift-overflow=2 as documented.

Next time also show the full command line that is used for compiling.

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

* [Bug target/115409] avx512 intrinsics trigger -Wshift-overflow
  2024-06-10  5:37 [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow collin.funk1 at gmail dot com
  2024-06-10  5:48 ` [Bug target/115409] " pinskia at gcc dot gnu.org
@ 2024-06-10  5:50 ` pinskia at gcc dot gnu.org
  2024-06-10  6:04 ` collin.funk1 at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-10  5:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the warning in this case normally does not show up unless you are using
-Wsystem-headers  . We should fix the warning still.

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

* [Bug target/115409] avx512 intrinsics trigger -Wshift-overflow
  2024-06-10  5:37 [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow collin.funk1 at gmail dot com
  2024-06-10  5:48 ` [Bug target/115409] " pinskia at gcc dot gnu.org
  2024-06-10  5:50 ` pinskia at gcc dot gnu.org
@ 2024-06-10  6:04 ` collin.funk1 at gmail dot com
  2024-06-10 20:11 ` egallager at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: collin.funk1 at gmail dot com @ 2024-06-10  6:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Collin Funk <collin.funk1 at gmail dot com> ---
Oops, Sorry about that. Here is the compile command:

gcc15.0  -I. -I./lib  -Ilib -I./lib -Isrc -I./src   -fstrict-flex-arrays -Wall
-Warith-conversion -Wbad-function-cast -Wcast-align=strict -Wdate-time
-Wdisabled-optimization -Wduplicated-cond -Wextra -Wformat-signedness
-Wflex-array-member-not-at-end -Winit-self -Winvalid-pch -Wlogical-op
-Wmissing-declarations -Wmissing-include-dirs -Wnull-dereference -Wopenmp-simd
-Woverlength-strings -Wpacked -Wpointer-arith -Wshadow -Wstrict-flex-arrays
-Wstrict-prototypes -Wsuggest-attribute=cold -Wsuggest-attribute=const
-Wsuggest-attribute=format -Wsuggest-attribute=malloc
-Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-final-methods
-Wsuggest-final-types -Wsync-nand -Wtrampolines -Wunknown-pragmas
-Wvariadic-macros -Wvla -Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2
-Wbidi-chars=any,ucn -Wformat=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2
-Wuse-after-free=3 -Wunused-const-variable=2 -Wvla-larger-than=4031
-Wno-sign-compare -Wno-unused-parameter -Wno-format-nonliteral
-fdiagnostics-show-option -funit-at-a-time -Wno-return-local-addr
-Wno-stringop-overflow -Wno-cast-qual -Wno-conversion -Wno-float-equal
-Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter
-Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion
-Wno-type-limits -Wno-unsuffixed-float-constants -g -O2 -MT
lib/libcoreutils_a-sm3.o -MD -MP -MF lib/.deps/libcoreutils_a-sm3.Tpo -c -o
lib/libcoreutils_a-sm3.o `test -f 'lib/sm3.c' || echo './'`lib/sm3.c
In file included from
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/immintrin.h:99:
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:
In function '_mm256_conj_pch':
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:184:80:
warning: result of '1 << 31' requires 33 bits to represent, but 'int' only has
32 bits [-Wshift-overflow=]
  184 |   return (__m256h) _mm256_xor_epi32 ((__m256i) __A,
_mm256_avx512_set1_epi32 (1<<31));
      |                                                                        
       ^~
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:
In function '_mm_conj_pch':
/home/collin/.local/lib/gcc/x86_64-pc-linux-gnu/15.0.0/include/avx512fp16vlintrin.h:212:74:
warning: result of '1 << 31' requires 33 bits to represent, but 'int' only has
32 bits [-Wshift-overflow=]
  212 |   return (__m128h) _mm_xor_epi32 ((__m128i) __A, _mm_avx512_set1_epi32
(1<<31));
      |                                                                        
 ^~

I'll read the page you sent and send a patch to gcc-patches referencing this
bug report.

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

* [Bug target/115409] avx512 intrinsics trigger -Wshift-overflow
  2024-06-10  5:37 [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow collin.funk1 at gmail dot com
                   ` (2 preceding siblings ...)
  2024-06-10  6:04 ` collin.funk1 at gmail dot com
@ 2024-06-10 20:11 ` egallager at gcc dot gnu.org
  2024-06-23  6:49 ` cvs-commit at gcc dot gnu.org
  2024-06-23 12:56 ` sjames at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: egallager at gcc dot gnu.org @ 2024-06-10 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2024-June/65
                   |                            |4016.html
                 CC|                            |egallager at gcc dot gnu.org
           Keywords|                            |patch

--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Collin Funk from comment #3)
> I'll read the page you sent and send a patch to gcc-patches referencing this
> bug report.

Linking the sent patch:
https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654016.html

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

* [Bug target/115409] avx512 intrinsics trigger -Wshift-overflow
  2024-06-10  5:37 [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow collin.funk1 at gmail dot com
                   ` (3 preceding siblings ...)
  2024-06-10 20:11 ` egallager at gcc dot gnu.org
@ 2024-06-23  6:49 ` cvs-commit at gcc dot gnu.org
  2024-06-23 12:56 ` sjames at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-23  6:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:4c957d7ba84d8bbce6e778048f38e92ef71806c8

commit r15-1563-g4c957d7ba84d8bbce6e778048f38e92ef71806c8
Author: Collin Funk <collin.funk1@gmail.com>
Date:   Mon Jun 10 06:36:47 2024 +0000

    AVX-512: Pacify -Wshift-overflow=2. [PR115409]

    A shift of 31 on a signed int is undefined behavior.  Since unsigned
    int is 32-bits wide this change fixes it and silences the warning.

    gcc/ChangeLog:

            PR target/115409
            * config/i386/avx512fp16intrin.h (_mm512_conj_pch): Make the
            constant unsigned before shifting.
            * config/i386/avx512fp16vlintrin.h (_mm256_conj_pch): Likewise.
            (_mm_conj_pch): Likewise.

    Signed-off-by: Collin Funk <collin.funk1@gmail.com>

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

* [Bug target/115409] avx512 intrinsics trigger -Wshift-overflow
  2024-06-10  5:37 [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow collin.funk1 at gmail dot com
                   ` (4 preceding siblings ...)
  2024-06-23  6:49 ` cvs-commit at gcc dot gnu.org
@ 2024-06-23 12:56 ` sjames at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-23 12:56 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |15.0

--- Comment #6 from Sam James <sjames at gcc dot gnu.org> ---
Fixed then.

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

end of thread, other threads:[~2024-06-23 12:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10  5:37 [Bug c/115409] New: avx512 intrinsics trigger -Wshift-overflow collin.funk1 at gmail dot com
2024-06-10  5:48 ` [Bug target/115409] " pinskia at gcc dot gnu.org
2024-06-10  5:50 ` pinskia at gcc dot gnu.org
2024-06-10  6:04 ` collin.funk1 at gmail dot com
2024-06-10 20:11 ` egallager at gcc dot gnu.org
2024-06-23  6:49 ` cvs-commit at gcc dot gnu.org
2024-06-23 12:56 ` sjames 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).