commit 0b935cee1da86981d6d35a7a425e0e283a690170
Author: Yukhin Kirill <kirill.yukhin@intel.com>
Date:   Tue Jun 21 14:13:46 2011 -0700

    New tests for AVX2 immediates.

diff --git a/gcc/ChangeLog.avx2 b/gcc/ChangeLog.avx2
index ec4e36a..9c01fb6 100644
--- a/gcc/ChangeLog.avx2
+++ b/gcc/ChangeLog.avx2
@@ -1,4 +1,9 @@
-+2011-06-20  Yukhin Kirill  <kirill.yukhin@intel.com>
+2011-06-20  Yukhin Kirill  <kirill.yukhin@intel.com>
+
+	* gcc/config/i386/i386.c (ix86_expand_args_builtin): Improved
+	error diagnistic for extracti128/inserti128 immediates.
+
+2011-06-20  Yukhin Kirill  <kirill.yukhin@intel.com>
 
 	* gcc/config/i386/sse.md (avx2_pshufdv3): Fixed immediate's
 	predicate.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 9980e57..a9490fd 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -26850,6 +26850,11 @@ ix86_expand_args_builtin (const struct builtin_description *d,
 	  if (!match)
 	    switch (icode)
 	      {
+	      case CODE_FOR_avx2_inserti128:
+	      case CODE_FOR_avx2_extracti128:
+		error ("the last argument must be an 1-bit immediate");
+		return const0_rtx;
+
 	      case CODE_FOR_sse4_1_roundpd:
 	      case CODE_FOR_sse4_1_roundps:
 	      case CODE_FOR_sse4_1_roundsd:
diff --git a/gcc/testsuite/ChangeLog.avx2 b/gcc/testsuite/ChangeLog.avx2
index c158afd..a211b3f 100644
--- a/gcc/testsuite/ChangeLog.avx2
+++ b/gcc/testsuite/ChangeLog.avx2
@@ -1,3 +1,22 @@
+2011-06-20  Yukhin Kirill  <kirill.yukhin@intel.com>
+
+	* gcc.target/i386/avx2-mpsadbw-3.c: New test to check error
+	diagnostic while passing wrong immediate.
+	* gcc.target/i386/avx2-vextracti128-3.c: Likewise.
+	* gcc.target/i386/avx2-vinserti128-3.c: Likewise.
+	* gcc.target/i386/avx2-vpalignr256-3.c: Likewise.
+	* gcc.target/i386/avx2-vpblendd128-3.c: Likewise.
+	* gcc.target/i386/avx2-vpblendd256-3.c: Likewise.
+	* gcc.target/i386/avx2-vpblendw-3.c: Likewise.
+	* gcc.target/i386/avx2-vperm2i128-3.c: Likewise.
+	* gcc.target/i386/avx2-vpermpd-3.c: Likewise.
+	* gcc.target/i386/avx2-vpermq-3.c: Likewise.
+	* gcc.target/i386/avx2-vpshufd-3.c: Likewise.
+	* gcc.target/i386/avx2-vpshufhw-3.c: Likewise.
+	* gcc.target/i386/avx2-vpshuflw-3.c: Likewise.
+	* gcc.target/i386/avx2-vpslldq-3.c: Likewise.
+	* gcc.target/i386/avx2-vpsrldq-3.c: Likewise.
+
 2011-06-10  Yukhin Kirill  <kirill.yukhin@intel.com>
 
 	* g++.dg/other/i386-2.C: Extended to check AVX2 as well.
diff --git a/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-3.c b/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-3.c
new file mode 100644
index 0000000..65beaf1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -mavx2" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_mpsadbw_epu8 (x, x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_mpsadbw_epu8 (x, x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_mpsadbw_epu8 (x, x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vextracti128-3.c b/gcc/testsuite/gcc.target/i386/avx2-vextracti128-3.c
new file mode 100644
index 0000000..1f81332
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vextracti128-3.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+__m128i y;
+int i;
+
+void static
+avx2_test (void)
+{
+  y = _mm256_extracti128_si256 (x, 2);  /* { dg-error "the last argument must be an 1-bit immediate" } */
+  y = _mm256_extracti128_si256 (x, -1); /* { dg-error "the last argument must be an 1-bit immediate" } */
+  y = _mm256_extracti128_si256 (x, i);  /* { dg-error "the last argument must be an 1-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vinserti128-3.c b/gcc/testsuite/gcc.target/i386/avx2-vinserti128-3.c
new file mode 100644
index 0000000..2f3d9b4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vinserti128-3.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+__m128i y;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_inserti128_si256 (x, y, 2);  /* { dg-error "the last argument must be an 1-bit immediate" } */
+  x = _mm256_inserti128_si256 (x, y, -1); /* { dg-error "the last argument must be an 1-bit immediate" } */
+  x = _mm256_inserti128_si256 (x, y, i);  /* { dg-error "the last argument must be an 1-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-3.c
new file mode 100644
index 0000000..554b3fa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -mavx2" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_alignr_epi8 (x, x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_alignr_epi8 (x, x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_alignr_epi8 (x, x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-3.c
new file mode 100644
index 0000000..2052a29
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m128i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm_blend_epi32 (x, x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm_blend_epi32 (x, x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm_blend_epi32 (x, x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-3.c
new file mode 100644
index 0000000..4ee97d5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_blend_epi32 (x, x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_blend_epi32 (x, x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_blend_epi32 (x, x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendw-3.c
new file mode 100644
index 0000000..0f16f2b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendw-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_blend_epi16(x, x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_blend_epi16(x, x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_blend_epi16(x, x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-3.c b/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-3.c
new file mode 100644
index 0000000..0159bff
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_permute2x128_si256 (x, x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_permute2x128_si256 (x, x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_permute2x128_si256 (x, x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermpd-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpermpd-3.c
new file mode 100644
index 0000000..e815f45
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermpd-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256d x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_permute4x64_pd (x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_permute4x64_pd (x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_permute4x64_pd (x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermq-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpermq-3.c
new file mode 100644
index 0000000..b28df0f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermq-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_permute4x64_epi64 (x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_permute4x64_epi64 (x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_permute4x64_epi64 (x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufd-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufd-3.c
new file mode 100644
index 0000000..9726065
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufd-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_shuffle_epi32 (x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_shuffle_epi32 (x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_shuffle_epi32 (x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-3.c
new file mode 100644
index 0000000..97599ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_shufflehi_epi16 (x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_shufflehi_epi16 (x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_shufflehi_epi16 (x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-3.c
new file mode 100644
index 0000000..f91d996
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+__m256i x;
+int i;
+
+void static
+avx2_test (void)
+{
+  x = _mm256_shufflelo_epi16 (x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_shufflelo_epi16 (x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_shufflelo_epi16 (x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpslldq-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpslldq-3.c
new file mode 100644
index 0000000..79cf2f5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpslldq-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+extern __m256i x;
+int i;
+
+void extern
+avx2_test (void)
+{
+  x = _mm256_slli_si256 (x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_slli_si256 (x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_slli_si256 (x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-3.c
new file mode 100644
index 0000000..c65afa3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O0" } */
+
+#include <immintrin.h>
+
+extern __m256i x;
+int i;
+
+void extern
+avx2_test (void)
+{
+  x = _mm256_srli_si256 (x, 257); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_srli_si256 (x, -1);  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  x = _mm256_srli_si256 (x, i);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
