diff --git a/gcc/config/i386/avx512bwintrin.h b/gcc/config/i386/avx512bwintrin.h
index 89790f7917b..791d4e35f32 100644
--- a/gcc/config/i386/avx512bwintrin.h
+++ b/gcc/config/i386/avx512bwintrin.h
@@ -2880,7 +2880,7 @@ _mm512_maskz_dbsad_epu8 (__mmask32 __U, __m512i __A, __m512i __B,
 
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_srli_epi16 (__m512i __A, const int __imm)
+_mm512_srli_epi16 (__m512i __A, const unsigned int __imm)
 {
   return (__m512i) __builtin_ia32_psrlwi512_mask ((__v32hi) __A, __imm,
 						  (__v32hi)
@@ -2891,7 +2891,7 @@ _mm512_srli_epi16 (__m512i __A, const int __imm)
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm512_mask_srli_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
-			const int __imm)
+			const unsigned int __imm)
 {
   return (__m512i) __builtin_ia32_psrlwi512_mask ((__v32hi) __A, __imm,
 						  (__v32hi) __W,
@@ -2910,7 +2910,7 @@ _mm512_maskz_srli_epi16 (__mmask32 __U, __m512i __A, const int __imm)
 
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_slli_epi16 (__m512i __A, const int __B)
+_mm512_slli_epi16 (__m512i __A, const unsigned int __B)
 {
   return (__m512i) __builtin_ia32_psllwi512_mask ((__v32hi) __A, __B,
 						  (__v32hi)
@@ -2921,7 +2921,7 @@ _mm512_slli_epi16 (__m512i __A, const int __B)
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm512_mask_slli_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
-			const int __B)
+			const unsigned int __B)
 {
   return (__m512i) __builtin_ia32_psllwi512_mask ((__v32hi) __A, __B,
 						  (__v32hi) __W,
@@ -2930,7 +2930,7 @@ _mm512_mask_slli_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
 
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_slli_epi16 (__mmask32 __U, __m512i __A, const int __B)
+_mm512_maskz_slli_epi16 (__mmask32 __U, __m512i __A, const unsigned int __B)
 {
   return (__m512i) __builtin_ia32_psllwi512_mask ((__v32hi) __A, __B,
 						  (__v32hi)
@@ -3008,7 +3008,7 @@ _mm512_maskz_shufflelo_epi16 (__mmask32 __U, __m512i __A,
 
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_srai_epi16 (__m512i __A, const int __imm)
+_mm512_srai_epi16 (__m512i __A, const unsigned int __imm)
 {
   return (__m512i) __builtin_ia32_psrawi512_mask ((__v32hi) __A, __imm,
 						  (__v32hi)
@@ -3019,7 +3019,7 @@ _mm512_srai_epi16 (__m512i __A, const int __imm)
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm512_mask_srai_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
-			const int __imm)
+			const unsigned int __imm)
 {
   return (__m512i) __builtin_ia32_psrawi512_mask ((__v32hi) __A, __imm,
 						  (__v32hi) __W,
@@ -3028,7 +3028,7 @@ _mm512_mask_srai_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
 
 extern __inline __m512i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_srai_epi16 (__mmask32 __U, __m512i __A, const int __imm)
+_mm512_maskz_srai_epi16 (__mmask32 __U, __m512i __A, const unsigned int __imm)
 {
   return (__m512i) __builtin_ia32_psrawi512_mask ((__v32hi) __A, __imm,
 						  (__v32hi)
@@ -3196,28 +3196,28 @@ _mm512_bsrli_epi128 (__m512i __A, const int __N)
 
 #define _mm512_srli_epi16(A, B)                                         \
   ((__m512i) __builtin_ia32_psrlwi512_mask ((__v32hi)(__m512i)(A),      \
-    (int)(B), (__v32hi)_mm512_setzero_si512 (), (__mmask32)-1))
+    (unsigned int)(B), (__v32hi)_mm512_setzero_si512 (), (__mmask32)-1))
 
 #define _mm512_mask_srli_epi16(W, U, A, B)                              \
   ((__m512i) __builtin_ia32_psrlwi512_mask ((__v32hi)(__m512i)(A),      \
-    (int)(B), (__v32hi)(__m512i)(W), (__mmask32)(U)))
+    (unsigned int)(B), (__v32hi)(__m512i)(W), (__mmask32)(U)))
 
 #define _mm512_maskz_srli_epi16(U, A, B)                                \
   ((__m512i) __builtin_ia32_psrlwi512_mask ((__v32hi)(__m512i)(A),      \
     (int)(B), (__v32hi)_mm512_setzero_si512 (), (__mmask32)(U)))
 
 #define _mm512_slli_epi16(X, C)						   \
-  ((__m512i)__builtin_ia32_psllwi512_mask ((__v32hi)(__m512i)(X), (int)(C),\
+  ((__m512i)__builtin_ia32_psllwi512_mask ((__v32hi)(__m512i)(X), (unsigned int)(C),\
     (__v32hi)(__m512i)_mm512_setzero_si512 (),				   \
     (__mmask32)-1))
 
 #define _mm512_mask_slli_epi16(W, U, X, C)                                 \
-  ((__m512i)__builtin_ia32_psllwi512_mask ((__v32hi)(__m512i)(X), (int)(C),\
+  ((__m512i)__builtin_ia32_psllwi512_mask ((__v32hi)(__m512i)(X), (unsigned int)(C),\
     (__v32hi)(__m512i)(W),\
     (__mmask32)(U)))
 
 #define _mm512_maskz_slli_epi16(U, X, C)                                   \
-  ((__m512i)__builtin_ia32_psllwi512_mask ((__v32hi)(__m512i)(X), (int)(C),\
+  ((__m512i)__builtin_ia32_psllwi512_mask ((__v32hi)(__m512i)(X), (unsigned int)(C),\
     (__v32hi)(__m512i)_mm512_setzero_si512 (),				   \
     (__mmask32)(U)))
 
@@ -3257,15 +3257,15 @@ _mm512_bsrli_epi128 (__m512i __A, const int __N)
 
 #define _mm512_srai_epi16(A, B)                                         \
   ((__m512i) __builtin_ia32_psrawi512_mask ((__v32hi)(__m512i)(A),      \
-    (int)(B), (__v32hi)_mm512_setzero_si512 (), (__mmask32)-1))
+    (unsigned int)(B), (__v32hi)_mm512_setzero_si512 (), (__mmask32)-1))
 
 #define _mm512_mask_srai_epi16(W, U, A, B)                              \
   ((__m512i) __builtin_ia32_psrawi512_mask ((__v32hi)(__m512i)(A),      \
-    (int)(B), (__v32hi)(__m512i)(W), (__mmask32)(U)))
+    (unsigned int)(B), (__v32hi)(__m512i)(W), (__mmask32)(U)))
 
 #define _mm512_maskz_srai_epi16(U, A, B)                                \
   ((__m512i) __builtin_ia32_psrawi512_mask ((__v32hi)(__m512i)(A),      \
-    (int)(B), (__v32hi)_mm512_setzero_si512 (), (__mmask32)(U)))
+    (unsigned int)(B), (__v32hi)_mm512_setzero_si512 (), (__mmask32)(U)))
 
 #define _mm512_mask_blend_epi16(__U, __A, __W)			      \
   ((__m512i) __builtin_ia32_blendmw_512_mask ((__v32hi) (__A),	      \
diff --git a/gcc/config/i386/avx512fintrin.h b/gcc/config/i386/avx512fintrin.h
index 89b321970cc..277260c3655 100644
--- a/gcc/config/i386/avx512fintrin.h
+++ b/gcc/config/i386/avx512fintrin.h
@@ -1038,17 +1038,20 @@ _mm512_maskz_slli_epi64 (__mmask8 __U, __m512i __A, unsigned int __B)
 }
 #else
 #define _mm512_slli_epi64(X, C)						   \
-  ((__m512i) __builtin_ia32_psllqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
-    (__v8di)(__m512i)_mm512_undefined_epi32 (),\
+  ((__m512i) __builtin_ia32_psllqi512_mask ((__v8di)(__m512i)(X),		\
+  	(unsigned int)(C),													\
+    (__v8di)(__m512i)_mm512_undefined_epi32 (),							\
     (__mmask8)-1))
 
 #define _mm512_mask_slli_epi64(W, U, X, C)				   \
-  ((__m512i) __builtin_ia32_psllqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
-    (__v8di)(__m512i)(W),\
+  ((__m512i) __builtin_ia32_psllqi512_mask ((__v8di)(__m512i)(X),		\
+  	(unsigned int)(C),													\
+    (__v8di)(__m512i)(W),												\
     (__mmask8)(U)))
 
 #define _mm512_maskz_slli_epi64(U, X, C)                                   \
-  ((__m512i) __builtin_ia32_psllqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psllqi512_mask ((__v8di)(__m512i)(X),			\
+  	(unsigned int)(C),														\
     (__v8di)(__m512i)_mm512_setzero_si512 (),\
     (__mmask8)(U)))
 #endif
@@ -1117,17 +1120,20 @@ _mm512_maskz_srli_epi64 (__mmask8 __U, __m512i __A, unsigned int __B)
 }
 #else
 #define _mm512_srli_epi64(X, C)						   \
-  ((__m512i) __builtin_ia32_psrlqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psrlqi512_mask ((__v8di)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v8di)(__m512i)_mm512_undefined_epi32 (),\
     (__mmask8)-1))
 
 #define _mm512_mask_srli_epi64(W, U, X, C)				   \
-  ((__m512i) __builtin_ia32_psrlqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psrlqi512_mask ((__v8di)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v8di)(__m512i)(W),\
     (__mmask8)(U)))
 
 #define _mm512_maskz_srli_epi64(U, X, C)                                   \
-  ((__m512i) __builtin_ia32_psrlqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psrlqi512_mask ((__v8di)(__m512i)(X),		\
+  	(unsigned int)(C),													\
     (__v8di)(__m512i)_mm512_setzero_si512 (),\
     (__mmask8)(U)))
 #endif
@@ -1196,17 +1202,20 @@ _mm512_maskz_srai_epi64 (__mmask8 __U, __m512i __A, unsigned int __B)
 }
 #else
 #define _mm512_srai_epi64(X, C)						   \
-  ((__m512i) __builtin_ia32_psraqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psraqi512_mask ((__v8di)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v8di)(__m512i)_mm512_undefined_epi32 (),\
     (__mmask8)-1))
 
 #define _mm512_mask_srai_epi64(W, U, X, C)				   \
-  ((__m512i) __builtin_ia32_psraqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psraqi512_mask ((__v8di)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v8di)(__m512i)(W),\
     (__mmask8)(U)))
 
 #define _mm512_maskz_srai_epi64(U, X, C)				   \
-  ((__m512i) __builtin_ia32_psraqi512_mask ((__v8di)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psraqi512_mask ((__v8di)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v8di)(__m512i)_mm512_setzero_si512 (),\
     (__mmask8)(U)))
 #endif
@@ -1275,17 +1284,20 @@ _mm512_maskz_slli_epi32 (__mmask16 __U, __m512i __A, unsigned int __B)
 }
 #else
 #define _mm512_slli_epi32(X, C)						    \
-  ((__m512i) __builtin_ia32_pslldi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_pslldi512_mask ((__v16si)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v16si)(__m512i)_mm512_undefined_epi32 (),\
     (__mmask16)-1))
 
 #define _mm512_mask_slli_epi32(W, U, X, C)                                  \
-  ((__m512i) __builtin_ia32_pslldi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_pslldi512_mask ((__v16si)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v16si)(__m512i)(W),\
     (__mmask16)(U)))
 
 #define _mm512_maskz_slli_epi32(U, X, C)                                    \
-  ((__m512i) __builtin_ia32_pslldi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_pslldi512_mask ((__v16si)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v16si)(__m512i)_mm512_setzero_si512 (),\
     (__mmask16)(U)))
 #endif
@@ -1354,17 +1366,20 @@ _mm512_maskz_srli_epi32 (__mmask16 __U, __m512i __A, unsigned int __B)
 }
 #else
 #define _mm512_srli_epi32(X, C)						    \
-  ((__m512i) __builtin_ia32_psrldi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psrldi512_mask ((__v16si)(__m512i)(X),		\
+  	(unsigned int)(C),													\
     (__v16si)(__m512i)_mm512_undefined_epi32 (),\
     (__mmask16)-1))
 
 #define _mm512_mask_srli_epi32(W, U, X, C)                                  \
-  ((__m512i) __builtin_ia32_psrldi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psrldi512_mask ((__v16si)(__m512i)(X),		\
+  	(unsigned int)(C),													\
     (__v16si)(__m512i)(W),\
     (__mmask16)(U)))
 
 #define _mm512_maskz_srli_epi32(U, X, C)				    \
-  ((__m512i) __builtin_ia32_psrldi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psrldi512_mask ((__v16si)(__m512i)(X),		\
+  	(unsigned int)(C),													\
     (__v16si)(__m512i)_mm512_setzero_si512 (),\
     (__mmask16)(U)))
 #endif
@@ -1433,17 +1448,20 @@ _mm512_maskz_srai_epi32 (__mmask16 __U, __m512i __A, unsigned int __B)
 }
 #else
 #define _mm512_srai_epi32(X, C)						    \
-  ((__m512i) __builtin_ia32_psradi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psradi512_mask ((__v16si)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v16si)(__m512i)_mm512_undefined_epi32 (),\
     (__mmask16)-1))
 
 #define _mm512_mask_srai_epi32(W, U, X, C)				    \
-  ((__m512i) __builtin_ia32_psradi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psradi512_mask ((__v16si)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v16si)(__m512i)(W),\
     (__mmask16)(U)))
 
 #define _mm512_maskz_srai_epi32(U, X, C)				    \
-  ((__m512i) __builtin_ia32_psradi512_mask ((__v16si)(__m512i)(X), (int)(C),\
+  ((__m512i) __builtin_ia32_psradi512_mask ((__v16si)(__m512i)(X),	\
+  	(unsigned int)(C),												\
     (__v16si)(__m512i)_mm512_setzero_si512 (),\
     (__mmask16)(U)))
 #endif
diff --git a/gcc/config/i386/avx512vlbwintrin.h b/gcc/config/i386/avx512vlbwintrin.h
index 3654cf214c4..b9d248b807b 100644
--- a/gcc/config/i386/avx512vlbwintrin.h
+++ b/gcc/config/i386/avx512vlbwintrin.h
@@ -1759,7 +1759,7 @@ _mm_maskz_shufflelo_epi16 (__mmask8 __U, __m128i __A, const int __imm)
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_srai_epi16 (__m256i __W, __mmask16 __U, __m256i __A,
-			const int __imm)
+			const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psrawi256_mask ((__v16hi) __A, __imm,
 						  (__v16hi) __W,
@@ -1768,7 +1768,7 @@ _mm256_mask_srai_epi16 (__m256i __W, __mmask16 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_srai_epi16 (__mmask16 __U, __m256i __A, const int __imm)
+_mm256_maskz_srai_epi16 (__mmask16 __U, __m256i __A, const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psrawi256_mask ((__v16hi) __A, __imm,
 						  (__v16hi)
@@ -1779,7 +1779,7 @@ _mm256_maskz_srai_epi16 (__mmask16 __U, __m256i __A, const int __imm)
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm_mask_srai_epi16 (__m128i __W, __mmask8 __U, __m128i __A,
-		     const int __imm)
+		     const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psrawi128_mask ((__v8hi) __A, __imm,
 						  (__v8hi) __W,
@@ -1788,7 +1788,7 @@ _mm_mask_srai_epi16 (__m128i __W, __mmask8 __U, __m128i __A,
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_srai_epi16 (__mmask8 __U, __m128i __A, const int __imm)
+_mm_maskz_srai_epi16 (__mmask8 __U, __m128i __A, const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psrawi128_mask ((__v8hi) __A, __imm,
 						  (__v8hi)
@@ -1799,7 +1799,7 @@ _mm_maskz_srai_epi16 (__mmask8 __U, __m128i __A, const int __imm)
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_slli_epi16 (__m256i __W, __mmask16 __U, __m256i __A,
-			int __B)
+			unsigned int __B)
 {
   return (__m256i) __builtin_ia32_psllwi256_mask ((__v16hi) __A, __B,
 						  (__v16hi) __W,
@@ -1808,7 +1808,7 @@ _mm256_mask_slli_epi16 (__m256i __W, __mmask16 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_slli_epi16 (__mmask16 __U, __m256i __A, int __B)
+_mm256_maskz_slli_epi16 (__mmask16 __U, __m256i __A, unsigned int __B)
 {
   return (__m256i) __builtin_ia32_psllwi256_mask ((__v16hi) __A, __B,
 						  (__v16hi)
@@ -1818,7 +1818,7 @@ _mm256_maskz_slli_epi16 (__mmask16 __U, __m256i __A, int __B)
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_slli_epi16 (__m128i __W, __mmask8 __U, __m128i __A, int __B)
+_mm_mask_slli_epi16 (__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B)
 {
   return (__m128i) __builtin_ia32_psllwi128_mask ((__v8hi) __A, __B,
 						  (__v8hi) __W,
@@ -1827,7 +1827,7 @@ _mm_mask_slli_epi16 (__m128i __W, __mmask8 __U, __m128i __A, int __B)
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_slli_epi16 (__mmask8 __U, __m128i __A, int __B)
+_mm_maskz_slli_epi16 (__mmask8 __U, __m128i __A, unsigned int __B)
 {
   return (__m128i) __builtin_ia32_psllwi128_mask ((__v8hi) __A, __B,
 						  (__v8hi)
@@ -1859,19 +1859,19 @@ _mm_maskz_slli_epi16 (__mmask8 __U, __m128i __A, int __B)
 
 #define _mm256_mask_srai_epi16(W, U, A, B)                              \
   ((__m256i) __builtin_ia32_psrawi256_mask ((__v16hi)(__m256i)(A),      \
-    (int)(B), (__v16hi)(__m256i)(W), (__mmask16)(U)))
+    (unsigned int)(B), (__v16hi)(__m256i)(W), (__mmask16)(U)))
 
 #define _mm256_maskz_srai_epi16(U, A, B)                                \
   ((__m256i) __builtin_ia32_psrawi256_mask ((__v16hi)(__m256i)(A),      \
-    (int)(B), (__v16hi)_mm256_setzero_si256 (), (__mmask16)(U)))
+    (unsigned int)(B), (__v16hi)_mm256_setzero_si256 (), (__mmask16)(U)))
 
 #define _mm_mask_srai_epi16(W, U, A, B)                                 \
   ((__m128i) __builtin_ia32_psrawi128_mask ((__v8hi)(__m128i)(A),       \
-    (int)(B), (__v8hi)(__m128i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v8hi)(__m128i)(W), (__mmask8)(U)))
 
 #define _mm_maskz_srai_epi16(U, A, B)                                   \
   ((__m128i) __builtin_ia32_psrawi128_mask ((__v8hi)(__m128i)(A),       \
-    (int)(B), (__v8hi)_mm_setzero_si128(), (__mmask8)(U)))
+    (unsigned int)(B), (__v8hi)_mm_setzero_si128(), (__mmask8)(U)))
 
 #define _mm256_mask_shufflehi_epi16(W, U, A, B)                                     \
   ((__m256i) __builtin_ia32_pshufhw256_mask ((__v16hi)(__m256i)(A), (int)(B),       \
@@ -1931,12 +1931,14 @@ _mm_maskz_slli_epi16 (__mmask8 __U, __m128i __A, int __B)
 					    (__mmask16)(U)))
 
 #define _mm_mask_slli_epi16(W, U, X, C)					  \
-  ((__m128i)__builtin_ia32_psllwi128_mask ((__v8hi)(__m128i)(X), (int)(C),\
+  ((__m128i)__builtin_ia32_psllwi128_mask ((__v8hi)(__m128i)(X),	\
+  	(unsigned int)(C),\
     (__v8hi)(__m128i)(W),\
     (__mmask8)(U)))
 
 #define _mm_maskz_slli_epi16(U, X, C)					  \
-  ((__m128i)__builtin_ia32_psllwi128_mask ((__v8hi)(__m128i)(X), (int)(C),\
+  ((__m128i)__builtin_ia32_psllwi128_mask ((__v8hi)(__m128i)(X),	\
+  	(unsigned int)(C),\
     (__v8hi)(__m128i)_mm_setzero_si128 (),\
     (__mmask8)(U)))
 
@@ -1947,12 +1949,14 @@ _mm_maskz_slli_epi16 (__mmask8 __U, __m128i __A, int __B)
                                               (__mmask16)-1))
 
 #define _mm256_mask_slli_epi16(W, U, X, C)                                 \
-  ((__m256i)__builtin_ia32_psllwi256_mask ((__v16hi)(__m256i)(X), (int)(C),\
+  ((__m256i)__builtin_ia32_psllwi256_mask ((__v16hi)(__m256i)(X),			\
+  	(unsigned int)(C),														\
     (__v16hi)(__m256i)(W),\
     (__mmask16)(U)))
 
 #define _mm256_maskz_slli_epi16(U, X, C)                                   \
-  ((__m256i)__builtin_ia32_psllwi256_mask ((__v16hi)(__m256i)(X), (int)(C),\
+  ((__m256i)__builtin_ia32_psllwi256_mask ((__v16hi)(__m256i)(X),			\
+  	(unsigned int)(C),														\
     (__v16hi)(__m256i)_mm256_setzero_si256 (),\
     (__mmask16)(U)))
 
diff --git a/gcc/config/i386/avx512vlintrin.h b/gcc/config/i386/avx512vlintrin.h
index 4a717a7e52f..8b055867986 100644
--- a/gcc/config/i386/avx512vlintrin.h
+++ b/gcc/config/i386/avx512vlintrin.h
@@ -10565,7 +10565,7 @@ _mm_maskz_fixupimm_ps (__mmask8 __U, __m128 __A, __m128 __B,
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_srli_epi32 (__m256i __W, __mmask8 __U, __m256i __A,
-			const int __imm)
+			const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psrldi256_mask ((__v8si) __A, __imm,
 						  (__v8si) __W,
@@ -10574,7 +10574,7 @@ _mm256_mask_srli_epi32 (__m256i __W, __mmask8 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_srli_epi32 (__mmask8 __U, __m256i __A, const int __imm)
+_mm256_maskz_srli_epi32 (__mmask8 __U, __m256i __A, const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psrldi256_mask ((__v8si) __A, __imm,
 						  (__v8si)
@@ -10585,7 +10585,7 @@ _mm256_maskz_srli_epi32 (__mmask8 __U, __m256i __A, const int __imm)
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm_mask_srli_epi32 (__m128i __W, __mmask8 __U, __m128i __A,
-		     const int __imm)
+		     const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psrldi128_mask ((__v4si) __A, __imm,
 						  (__v4si) __W,
@@ -10594,7 +10594,7 @@ _mm_mask_srli_epi32 (__m128i __W, __mmask8 __U, __m128i __A,
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_srli_epi32 (__mmask8 __U, __m128i __A, const int __imm)
+_mm_maskz_srli_epi32 (__mmask8 __U, __m128i __A, const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psrldi128_mask ((__v4si) __A, __imm,
 						  (__v4si)
@@ -10605,7 +10605,7 @@ _mm_maskz_srli_epi32 (__mmask8 __U, __m128i __A, const int __imm)
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_srli_epi64 (__m256i __W, __mmask8 __U, __m256i __A,
-			const int __imm)
+			const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psrlqi256_mask ((__v4di) __A, __imm,
 						  (__v4di) __W,
@@ -10614,7 +10614,7 @@ _mm256_mask_srli_epi64 (__m256i __W, __mmask8 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_srli_epi64 (__mmask8 __U, __m256i __A, const int __imm)
+_mm256_maskz_srli_epi64 (__mmask8 __U, __m256i __A, const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psrlqi256_mask ((__v4di) __A, __imm,
 						  (__v4di)
@@ -10625,7 +10625,7 @@ _mm256_maskz_srli_epi64 (__mmask8 __U, __m256i __A, const int __imm)
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm_mask_srli_epi64 (__m128i __W, __mmask8 __U, __m128i __A,
-		     const int __imm)
+		     const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psrlqi128_mask ((__v2di) __A, __imm,
 						  (__v2di) __W,
@@ -10634,7 +10634,7 @@ _mm_mask_srli_epi64 (__m128i __W, __mmask8 __U, __m128i __A,
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_srli_epi64 (__mmask8 __U, __m128i __A, const int __imm)
+_mm_maskz_srli_epi64 (__mmask8 __U, __m128i __A, const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psrlqi128_mask ((__v2di) __A, __imm,
 						  (__v2di)
@@ -12059,7 +12059,7 @@ _mm256_maskz_cvtps_ph (__mmask8 __U, __m256 __A, const int __I)
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_srai_epi32 (__m256i __W, __mmask8 __U, __m256i __A,
-			const int __imm)
+			const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psradi256_mask ((__v8si) __A, __imm,
 						  (__v8si) __W,
@@ -12068,7 +12068,7 @@ _mm256_mask_srai_epi32 (__m256i __W, __mmask8 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_srai_epi32 (__mmask8 __U, __m256i __A, const int __imm)
+_mm256_maskz_srai_epi32 (__mmask8 __U, __m256i __A, const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psradi256_mask ((__v8si) __A, __imm,
 						  (__v8si)
@@ -12079,7 +12079,7 @@ _mm256_maskz_srai_epi32 (__mmask8 __U, __m256i __A, const int __imm)
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm_mask_srai_epi32 (__m128i __W, __mmask8 __U, __m128i __A,
-		     const int __imm)
+		     const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psradi128_mask ((__v4si) __A, __imm,
 						  (__v4si) __W,
@@ -12088,7 +12088,7 @@ _mm_mask_srai_epi32 (__m128i __W, __mmask8 __U, __m128i __A,
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_srai_epi32 (__mmask8 __U, __m128i __A, const int __imm)
+_mm_maskz_srai_epi32 (__mmask8 __U, __m128i __A, const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psradi128_mask ((__v4si) __A, __imm,
 						  (__v4si)
@@ -12098,7 +12098,7 @@ _mm_maskz_srai_epi32 (__mmask8 __U, __m128i __A, const int __imm)
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_srai_epi64 (__m256i __A, const int __imm)
+_mm256_srai_epi64 (__m256i __A, const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psraqi256_mask ((__v4di) __A, __imm,
 						  (__v4di)
@@ -12109,7 +12109,7 @@ _mm256_srai_epi64 (__m256i __A, const int __imm)
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_srai_epi64 (__m256i __W, __mmask8 __U, __m256i __A,
-			const int __imm)
+			const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psraqi256_mask ((__v4di) __A, __imm,
 						  (__v4di) __W,
@@ -12118,7 +12118,7 @@ _mm256_mask_srai_epi64 (__m256i __W, __mmask8 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_srai_epi64 (__mmask8 __U, __m256i __A, const int __imm)
+_mm256_maskz_srai_epi64 (__mmask8 __U, __m256i __A, const unsigned int __imm)
 {
   return (__m256i) __builtin_ia32_psraqi256_mask ((__v4di) __A, __imm,
 						  (__v4di)
@@ -12128,7 +12128,7 @@ _mm256_maskz_srai_epi64 (__mmask8 __U, __m256i __A, const int __imm)
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_srai_epi64 (__m128i __A, const int __imm)
+_mm_srai_epi64 (__m128i __A, const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psraqi128_mask ((__v2di) __A, __imm,
 						  (__v2di)
@@ -12139,7 +12139,7 @@ _mm_srai_epi64 (__m128i __A, const int __imm)
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm_mask_srai_epi64 (__m128i __W, __mmask8 __U, __m128i __A,
-		     const int __imm)
+		     const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psraqi128_mask ((__v2di) __A, __imm,
 						  (__v2di) __W,
@@ -12148,7 +12148,7 @@ _mm_mask_srai_epi64 (__m128i __W, __mmask8 __U, __m128i __A,
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_srai_epi64 (__mmask8 __U, __m128i __A, const int __imm)
+_mm_maskz_srai_epi64 (__mmask8 __U, __m128i __A, const unsigned int __imm)
 {
   return (__m128i) __builtin_ia32_psraqi128_mask ((__v2di) __A, __imm,
 						  (__v2di)
@@ -12158,7 +12158,7 @@ _mm_maskz_srai_epi64 (__mmask8 __U, __m128i __A, const int __imm)
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_slli_epi32 (__m128i __W, __mmask8 __U, __m128i __A, int __B)
+_mm_mask_slli_epi32 (__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B)
 {
   return (__m128i) __builtin_ia32_pslldi128_mask ((__v4si) __A, __B,
 						  (__v4si) __W,
@@ -12167,7 +12167,7 @@ _mm_mask_slli_epi32 (__m128i __W, __mmask8 __U, __m128i __A, int __B)
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_slli_epi32 (__mmask8 __U, __m128i __A, int __B)
+_mm_maskz_slli_epi32 (__mmask8 __U, __m128i __A, unsigned int __B)
 {
   return (__m128i) __builtin_ia32_pslldi128_mask ((__v4si) __A, __B,
 						  (__v4si)
@@ -12177,7 +12177,7 @@ _mm_maskz_slli_epi32 (__mmask8 __U, __m128i __A, int __B)
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_mask_slli_epi64 (__m128i __W, __mmask8 __U, __m128i __A, int __B)
+_mm_mask_slli_epi64 (__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B)
 {
   return (__m128i) __builtin_ia32_psllqi128_mask ((__v2di) __A, __B,
 						  (__v2di) __W,
@@ -12186,7 +12186,7 @@ _mm_mask_slli_epi64 (__m128i __W, __mmask8 __U, __m128i __A, int __B)
 
 extern __inline __m128i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm_maskz_slli_epi64 (__mmask8 __U, __m128i __A, int __B)
+_mm_maskz_slli_epi64 (__mmask8 __U, __m128i __A, unsigned int __B)
 {
   return (__m128i) __builtin_ia32_psllqi128_mask ((__v2di) __A, __B,
 						  (__v2di)
@@ -12197,7 +12197,7 @@ _mm_maskz_slli_epi64 (__mmask8 __U, __m128i __A, int __B)
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_slli_epi32 (__m256i __W, __mmask8 __U, __m256i __A,
-			int __B)
+			unsigned int __B)
 {
   return (__m256i) __builtin_ia32_pslldi256_mask ((__v8si) __A, __B,
 						  (__v8si) __W,
@@ -12206,7 +12206,7 @@ _mm256_mask_slli_epi32 (__m256i __W, __mmask8 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_slli_epi32 (__mmask8 __U, __m256i __A, int __B)
+_mm256_maskz_slli_epi32 (__mmask8 __U, __m256i __A, unsigned int __B)
 {
   return (__m256i) __builtin_ia32_pslldi256_mask ((__v8si) __A, __B,
 						  (__v8si)
@@ -12217,7 +12217,7 @@ _mm256_maskz_slli_epi32 (__mmask8 __U, __m256i __A, int __B)
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm256_mask_slli_epi64 (__m256i __W, __mmask8 __U, __m256i __A,
-			int __B)
+			unsigned int __B)
 {
   return (__m256i) __builtin_ia32_psllqi256_mask ((__v4di) __A, __B,
 						  (__v4di) __W,
@@ -12226,7 +12226,7 @@ _mm256_mask_slli_epi64 (__m256i __W, __mmask8 __U, __m256i __A,
 
 extern __inline __m256i
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm256_maskz_slli_epi64 (__mmask8 __U, __m256i __A, int __B)
+_mm256_maskz_slli_epi64 (__mmask8 __U, __m256i __A, unsigned int __B)
 {
   return (__m256i) __builtin_ia32_psllqi256_mask ((__v4di) __A, __B,
 						  (__v4di)
@@ -12864,73 +12864,81 @@ _mm256_permutex_pd (__m256d __X, const int __M)
 
 #define _mm256_mask_srli_epi32(W, U, A, B)				\
   ((__m256i) __builtin_ia32_psrldi256_mask ((__v8si)(__m256i)(A),	\
-    (int)(B), (__v8si)(__m256i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v8si)(__m256i)(W), (__mmask8)(U)))
 
 #define _mm256_maskz_srli_epi32(U, A, B)				\
   ((__m256i) __builtin_ia32_psrldi256_mask ((__v8si)(__m256i)(A),	\
-    (int)(B), (__v8si)_mm256_setzero_si256 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v8si)_mm256_setzero_si256 (), (__mmask8)(U)))
 
 #define _mm_mask_srli_epi32(W, U, A, B)                                 \
   ((__m128i) __builtin_ia32_psrldi128_mask ((__v4si)(__m128i)(A),       \
-    (int)(B), (__v4si)(__m128i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v4si)(__m128i)(W), (__mmask8)(U)))
 
 #define _mm_maskz_srli_epi32(U, A, B)                                   \
   ((__m128i) __builtin_ia32_psrldi128_mask ((__v4si)(__m128i)(A),       \
-    (int)(B), (__v4si)_mm_setzero_si128 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v4si)_mm_setzero_si128 (), (__mmask8)(U)))
 
 #define _mm256_mask_srli_epi64(W, U, A, B)				\
   ((__m256i) __builtin_ia32_psrlqi256_mask ((__v4di)(__m256i)(A),	\
-    (int)(B), (__v4di)(__m256i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v4di)(__m256i)(W), (__mmask8)(U)))
 
 #define _mm256_maskz_srli_epi64(U, A, B)				\
   ((__m256i) __builtin_ia32_psrlqi256_mask ((__v4di)(__m256i)(A),	\
-    (int)(B), (__v4di)_mm256_setzero_si256 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v4di)_mm256_setzero_si256 (), (__mmask8)(U)))
 
 #define _mm_mask_srli_epi64(W, U, A, B)                                 \
   ((__m128i) __builtin_ia32_psrlqi128_mask ((__v2di)(__m128i)(A),       \
-    (int)(B), (__v2di)(__m128i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v2di)(__m128i)(W), (__mmask8)(U)))
 
 #define _mm_maskz_srli_epi64(U, A, B)                                   \
   ((__m128i) __builtin_ia32_psrlqi128_mask ((__v2di)(__m128i)(A),       \
-    (int)(B), (__v2di)_mm_setzero_si128 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v2di)_mm_setzero_si128 (), (__mmask8)(U)))
 
 #define _mm256_mask_slli_epi32(W, U, X, C)                                \
-  ((__m256i)__builtin_ia32_pslldi256_mask ((__v8si)(__m256i)(X), (int)(C),\
+  ((__m256i)__builtin_ia32_pslldi256_mask ((__v8si)(__m256i)(X),			\
+  	(unsigned int)(C),														\
     (__v8si)(__m256i)(W),						  \
     (__mmask8)(U)))
 
 #define _mm256_maskz_slli_epi32(U, X, C)                                  \
-  ((__m256i)__builtin_ia32_pslldi256_mask ((__v8si)(__m256i)(X), (int)(C),\
+  ((__m256i)__builtin_ia32_pslldi256_mask ((__v8si)(__m256i)(X),			\
+  	(unsigned int)(C),														\
     (__v8si)(__m256i)_mm256_setzero_si256 (),				  \
     (__mmask8)(U)))
 
 #define _mm256_mask_slli_epi64(W, U, X, C)                                \
-  ((__m256i)__builtin_ia32_psllqi256_mask ((__v4di)(__m256i)(X), (int)(C),\
+  ((__m256i)__builtin_ia32_psllqi256_mask ((__v4di)(__m256i)(X),		\
+  	(unsigned int)(C),													\
     (__v4di)(__m256i)(W),						  \
     (__mmask8)(U)))
 
 #define _mm256_maskz_slli_epi64(U, X, C)                                  \
-  ((__m256i)__builtin_ia32_psllqi256_mask ((__v4di)(__m256i)(X), (int)(C),\
+  ((__m256i)__builtin_ia32_psllqi256_mask ((__v4di)(__m256i)(X),		\
+  	(unsigned int)(C),													\
     (__v4di)(__m256i)_mm256_setzero_si256 (),				  \
     (__mmask8)(U)))
 
 #define _mm_mask_slli_epi32(W, U, X, C)					  \
-  ((__m128i)__builtin_ia32_pslldi128_mask ((__v4si)(__m128i)(X), (int)(C),\
+  ((__m128i)__builtin_ia32_pslldi128_mask ((__v4si)(__m128i)(X),		\
+  	(unsigned int)(C),													\
     (__v4si)(__m128i)(W),\
     (__mmask8)(U)))
 
 #define _mm_maskz_slli_epi32(U, X, C)					  \
-  ((__m128i)__builtin_ia32_pslldi128_mask ((__v4si)(__m128i)(X), (int)(C),\
+  ((__m128i)__builtin_ia32_pslldi128_mask ((__v4si)(__m128i)(X),		\
+  	(unsigned int)(C),													\
     (__v4si)(__m128i)_mm_setzero_si128 (),\
     (__mmask8)(U)))
 
 #define _mm_mask_slli_epi64(W, U, X, C)					  \
-  ((__m128i)__builtin_ia32_psllqi128_mask ((__v2di)(__m128i)(X), (int)(C),\
+  ((__m128i)__builtin_ia32_psllqi128_mask ((__v2di)(__m128i)(X),		\
+  	(unsigned int)(C),													\
     (__v2di)(__m128i)(W),\
     (__mmask8)(U)))
 
 #define _mm_maskz_slli_epi64(U, X, C)					  \
-  ((__m128i)__builtin_ia32_psllqi128_mask ((__v2di)(__m128i)(X), (int)(C),\
+  ((__m128i)__builtin_ia32_psllqi128_mask ((__v2di)(__m128i)(X),		\
+  	(unsigned int)(C),													\
     (__v2di)(__m128i)_mm_setzero_si128 (),\
     (__mmask8)(U)))
 
@@ -13634,43 +13642,43 @@ _mm256_permutex_pd (__m256d __X, const int __M)
 
 #define _mm256_mask_srai_epi32(W, U, A, B)				\
   ((__m256i) __builtin_ia32_psradi256_mask ((__v8si)(__m256i)(A),	\
-    (int)(B), (__v8si)(__m256i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v8si)(__m256i)(W), (__mmask8)(U)))
 
 #define _mm256_maskz_srai_epi32(U, A, B)				\
   ((__m256i) __builtin_ia32_psradi256_mask ((__v8si)(__m256i)(A),	\
-    (int)(B), (__v8si)_mm256_setzero_si256 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v8si)_mm256_setzero_si256 (), (__mmask8)(U)))
 
 #define _mm_mask_srai_epi32(W, U, A, B)                                 \
   ((__m128i) __builtin_ia32_psradi128_mask ((__v4si)(__m128i)(A),       \
-    (int)(B), (__v4si)(__m128i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v4si)(__m128i)(W), (__mmask8)(U)))
 
 #define _mm_maskz_srai_epi32(U, A, B)                                   \
   ((__m128i) __builtin_ia32_psradi128_mask ((__v4si)(__m128i)(A),       \
-    (int)(B), (__v4si)_mm_setzero_si128 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v4si)_mm_setzero_si128 (), (__mmask8)(U)))
 
 #define _mm256_srai_epi64(A, B)						\
   ((__m256i) __builtin_ia32_psraqi256_mask ((__v4di)(__m256i)(A),	\
-    (int)(B), (__v4di)_mm256_setzero_si256 (), (__mmask8)-1))
+    (unsigned int)(B), (__v4di)_mm256_setzero_si256 (), (__mmask8)-1))
 
 #define _mm256_mask_srai_epi64(W, U, A, B)				\
   ((__m256i) __builtin_ia32_psraqi256_mask ((__v4di)(__m256i)(A),	\
-    (int)(B), (__v4di)(__m256i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v4di)(__m256i)(W), (__mmask8)(U)))
 
 #define _mm256_maskz_srai_epi64(U, A, B)				\
   ((__m256i) __builtin_ia32_psraqi256_mask ((__v4di)(__m256i)(A),	\
-    (int)(B), (__v4di)_mm256_setzero_si256 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v4di)_mm256_setzero_si256 (), (__mmask8)(U)))
 
 #define _mm_srai_epi64(A, B)						\
   ((__m128i) __builtin_ia32_psraqi128_mask ((__v2di)(__m128i)(A),       \
-    (int)(B), (__v2di)_mm_setzero_si128 (), (__mmask8)-1))
+    (unsigned int)(B), (__v2di)_mm_setzero_si128 (), (__mmask8)-1))
 
 #define _mm_mask_srai_epi64(W, U, A, B)                                 \
   ((__m128i) __builtin_ia32_psraqi128_mask ((__v2di)(__m128i)(A),       \
-    (int)(B), (__v2di)(__m128i)(W), (__mmask8)(U)))
+    (unsigned int)(B), (__v2di)(__m128i)(W), (__mmask8)(U)))
 
 #define _mm_maskz_srai_epi64(U, A, B)                                   \
   ((__m128i) __builtin_ia32_psraqi128_mask ((__v2di)(__m128i)(A),       \
-    (int)(B), (__v2di)_mm_setzero_si128 (), (__mmask8)(U)))
+    (unsigned int)(B), (__v2di)_mm_setzero_si128 (), (__mmask8)(U)))
 
 #define _mm256_mask_permutex_pd(W, U, A, B)                             \
   ((__m256d) __builtin_ia32_permdf256_mask ((__v4df)(__m256d)(A),       \
diff --git a/gcc/testsuite/gcc.target/i386/pr109173-1.c b/gcc/testsuite/gcc.target/i386/pr109173-1.c
new file mode 100644
index 00000000000..286939e56be
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr109173-1.c
@@ -0,0 +1,57 @@
+/* PR target/109173 */
+/* { dg-do compile } */
+/* { dg-options "-c -Wsign-conversion -Werror -mavx512bw -mavx512vl -O2"  } */
+
+#include <immintrin.h>
+
+extern unsigned int bar();
+
+void foo()
+{
+  __m128i a1, w1;
+  __m256i a2, w2;
+  __mmask8 u;
+
+  _mm256_mask_srli_epi32(w2, u, a2, bar());
+  _mm256_maskz_srli_epi32(u, a2, bar());
+  _mm_mask_srli_epi32(w1, u, a1, bar());
+  _mm_maskz_srli_epi32(u, a1, bar());
+
+  _mm256_mask_srli_epi64(w2, u, a2, bar());
+  _mm256_maskz_srli_epi64(u, a2, bar());
+  _mm_mask_srli_epi64(w1, u, a1, bar());
+  _mm_maskz_srli_epi64(u, a1, bar());
+
+  _mm256_mask_srai_epi32(w2, u, a2, bar());
+  _mm256_maskz_srai_epi32(u, a2, bar());
+  _mm_mask_srai_epi32(w1, u, a1, bar());
+  _mm_maskz_srai_epi32(u, a1, bar());
+
+  _mm256_srai_epi64(a2, bar());
+  _mm256_mask_srai_epi64(w2, u, a2, bar());
+  _mm256_maskz_srai_epi64(u, a2, bar());
+  _mm_srai_epi64(a1, bar());
+  _mm_mask_srai_epi64(w1, u, a1, bar());
+  _mm_maskz_srai_epi64(u, a1, bar());
+
+  _mm256_mask_slli_epi32(w2, u, a2, bar());
+  _mm256_maskz_slli_epi32(u, a2, bar());
+  _mm_mask_slli_epi32(w1, u, a1, bar());
+  _mm_maskz_slli_epi32(u, a1, bar());
+
+  _mm256_mask_slli_epi64(w2, u, a2, bar());
+  _mm256_maskz_slli_epi64(u, a2, bar());
+  _mm_mask_slli_epi64(w1, u, a1, bar());
+  _mm_maskz_slli_epi64(u, a1, bar());
+
+  _mm256_mask_srai_epi16(w2, u, a2, bar());
+  _mm256_maskz_srai_epi16(u, a2, bar());
+  _mm_mask_srai_epi16(w1, u, a1, bar());
+  _mm_maskz_srai_epi16(u, a1, bar());
+
+  _mm256_mask_slli_epi16(w2, u, a2, bar());
+  _mm256_maskz_slli_epi16(u, a2, bar());
+  _mm_mask_slli_epi16(w1, u, a1, bar());
+  _mm_maskz_slli_epi16(u, a1, bar());
+}
+
diff --git a/gcc/testsuite/gcc.target/i386/pr109174-1.c b/gcc/testsuite/gcc.target/i386/pr109174-1.c
new file mode 100644
index 00000000000..119721bccf0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr109174-1.c
@@ -0,0 +1,45 @@
+/* PR target/109174 */
+/* { dg-do compile } */
+/* { dg-options "-c -Wsign-conversion -Werror -mavx512bw -O2"  } */
+
+#include <immintrin.h>
+
+extern unsigned int bar();
+
+void foo()
+{ 
+  __m512i a, w;
+  __mmask32 u1;
+  __mmask16 u2;
+  __mmask8 u3;
+  
+  _mm512_slli_epi64(a, bar());
+  _mm512_mask_slli_epi64(w, u3, a, bar());
+  _mm512_maskz_slli_epi64(u3, a, bar());
+  _mm512_slli_epi32(a, bar());
+  _mm512_mask_slli_epi32(w, u2, a, bar());
+  _mm512_maskz_slli_epi32(u2, a, bar());
+  _mm512_slli_epi16(a, bar());
+  _mm512_mask_slli_epi16(w, u1, a, bar());
+  _mm512_maskz_slli_epi16(u1, a, bar());
+
+  _mm512_srai_epi64(a, bar());
+  _mm512_mask_srai_epi64(w, u3, a, bar());
+  _mm512_maskz_srai_epi64(u3, a, bar());
+  _mm512_srai_epi32(a, bar());
+  _mm512_mask_srai_epi32(w, u2, a, bar());
+  _mm512_maskz_srai_epi32(u2, a, bar());
+  _mm512_srai_epi16(a, bar());
+  _mm512_mask_srai_epi16(w, u1, a, bar());
+  _mm512_maskz_srai_epi16(u1, a, bar());
+
+  _mm512_srli_epi64(a, bar());
+  _mm512_mask_srli_epi64(w, u3, a, bar());
+  _mm512_maskz_srli_epi64(u3, a, bar());
+  _mm512_srli_epi32(a, bar());
+  _mm512_mask_srli_epi32(w, u2, a, bar());
+  _mm512_maskz_srli_epi32(u2, a, bar());
+  _mm512_srli_epi16(a, bar());
+  _mm512_mask_srli_epi16(w, u1, a, bar());
+}
+
