Message ID | 20240610063713.837353-1-collin.funk1@gmail.com |
---|---|
State | New |
Headers | show |
Series | AVX-512: Pacify -Wshift-overflow=2. [PR115409] | expand |
On Mon, Jun 10, 2024 at 2:37 PM Collin Funk <collin.funk1@gmail.com> wrote: > > 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. Ok. > > 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> > --- > gcc/config/i386/avx512fp16intrin.h | 2 +- > gcc/config/i386/avx512fp16vlintrin.h | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gcc/config/i386/avx512fp16intrin.h b/gcc/config/i386/avx512fp16intrin.h > index f86050b2087..1869a920dd3 100644 > --- a/gcc/config/i386/avx512fp16intrin.h > +++ b/gcc/config/i386/avx512fp16intrin.h > @@ -3355,7 +3355,7 @@ extern __inline __m512h > __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > _mm512_conj_pch (__m512h __A) > { > - return (__m512h) _mm512_xor_epi32 ((__m512i) __A, _mm512_set1_epi32 (1<<31)); > + return (__m512h) _mm512_xor_epi32 ((__m512i) __A, _mm512_set1_epi32 (1U<<31)); > } > > extern __inline __m512h > diff --git a/gcc/config/i386/avx512fp16vlintrin.h b/gcc/config/i386/avx512fp16vlintrin.h > index a1e1cb567ff..405a06bbb9e 100644 > --- a/gcc/config/i386/avx512fp16vlintrin.h > +++ b/gcc/config/i386/avx512fp16vlintrin.h > @@ -181,7 +181,7 @@ extern __inline __m256h > __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > _mm256_conj_pch (__m256h __A) > { > - return (__m256h) _mm256_xor_epi32 ((__m256i) __A, _mm256_avx512_set1_epi32 (1<<31)); > + return (__m256h) _mm256_xor_epi32 ((__m256i) __A, _mm256_avx512_set1_epi32 (1U<<31)); > } > > extern __inline __m256h > @@ -209,7 +209,7 @@ extern __inline __m128h > __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > _mm_conj_pch (__m128h __A) > { > - return (__m128h) _mm_xor_epi32 ((__m128i) __A, _mm_avx512_set1_epi32 (1<<31)); > + return (__m128h) _mm_xor_epi32 ((__m128i) __A, _mm_avx512_set1_epi32 (1U<<31)); > } > > extern __inline __m128h > -- > 2.45.2 >
diff --git a/gcc/config/i386/avx512fp16intrin.h b/gcc/config/i386/avx512fp16intrin.h index f86050b2087..1869a920dd3 100644 --- a/gcc/config/i386/avx512fp16intrin.h +++ b/gcc/config/i386/avx512fp16intrin.h @@ -3355,7 +3355,7 @@ extern __inline __m512h __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_conj_pch (__m512h __A) { - return (__m512h) _mm512_xor_epi32 ((__m512i) __A, _mm512_set1_epi32 (1<<31)); + return (__m512h) _mm512_xor_epi32 ((__m512i) __A, _mm512_set1_epi32 (1U<<31)); } extern __inline __m512h diff --git a/gcc/config/i386/avx512fp16vlintrin.h b/gcc/config/i386/avx512fp16vlintrin.h index a1e1cb567ff..405a06bbb9e 100644 --- a/gcc/config/i386/avx512fp16vlintrin.h +++ b/gcc/config/i386/avx512fp16vlintrin.h @@ -181,7 +181,7 @@ extern __inline __m256h __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm256_conj_pch (__m256h __A) { - return (__m256h) _mm256_xor_epi32 ((__m256i) __A, _mm256_avx512_set1_epi32 (1<<31)); + return (__m256h) _mm256_xor_epi32 ((__m256i) __A, _mm256_avx512_set1_epi32 (1U<<31)); } extern __inline __m256h @@ -209,7 +209,7 @@ extern __inline __m128h __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm_conj_pch (__m128h __A) { - return (__m128h) _mm_xor_epi32 ((__m128i) __A, _mm_avx512_set1_epi32 (1<<31)); + return (__m128h) _mm_xor_epi32 ((__m128i) __A, _mm_avx512_set1_epi32 (1U<<31)); } extern __inline __m128h
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> --- gcc/config/i386/avx512fp16intrin.h | 2 +- gcc/config/i386/avx512fp16vlintrin.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)