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.

Reply via email to