re PR target/49411 ([4.6/4.7] ICE: unrecognizable insn with -mxop in _mm_roti_epi8...
authorJakub Jelinek <jakub@redhat.com>
Sat, 18 Jun 2011 06:43:38 +0000 (08:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 18 Jun 2011 06:43:38 +0000 (08:43 +0200)
PR target/49411
* config/i386/i386.c (ix86_expand_multi_arg_builtins): If
last_arg_constant and last argument doesn't match its predicate,
for xop_vpermil2<mode>3 error out and for xop_rotl<mode>3
if it is CONST_INT, mask it, otherwise expand using rotl<mode>3.
(ix86_expand_sse_pcmpestr, ix86_expand_sse_pcmpistr): Fix
spelling of error message.
* config/i386/sse.md (sse4a_extrqi, sse4a_insertqi,
vcvtps2ph, *vcvtps2ph, *vcvtps2ph_store, vcvtps2ph256): Use
const_0_to_255_operand instead of const_int_operand.

Revert:
2011-05-09  Uros Bizjak  <ubizjak@gmail.com>

* config/i386/sse.md (blendbits): Remove mode attribute.
(<sse4_1>_blend<ssemodesuffix><avxsizesuffix>): Use const_int_operand
instead of const_0_to_<blendbits>_operand for operand 3 predicate.
Check integer value of operand 3 in insn constraint.

* gcc.target/i386/testimm-1.c: New test.
* gcc.target/i386/testimm-2.c: New test.
* gcc.target/i386/testimm-3.c: New test.
* gcc.target/i386/testimm-4.c: New test.
* gcc.target/i386/testimm-5.c: New test.
* gcc.target/i386/testimm-6.c: New test.
* gcc.target/i386/testimm-7.c: New test.
* gcc.target/i386/testimm-8.c: New test.
* gcc.target/i386/xop-vpermil2px-2.c: New test.
* gcc.target/i386/xop-rotate1-int.c: New test.
* gcc.target/i386/xop-rotate2-int.c: New test.

From-SVN: r175165

14 files changed:
gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/sse.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/testimm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/testimm-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/testimm-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/testimm-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/testimm-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/testimm-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/testimm-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/testimm-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/xop-rotate1-int.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/xop-rotate2-int.c [new file with mode: 0644]

index 26c1f81..8043163 100644 (file)
@@ -1,3 +1,24 @@
+2011-06-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/49411
+       * config/i386/i386.c (ix86_expand_multi_arg_builtins): If
+       last_arg_constant and last argument doesn't match its predicate,
+       for xop_vpermil2<mode>3 error out and for xop_rotl<mode>3
+       if it is CONST_INT, mask it, otherwise expand using rotl<mode>3.
+       (ix86_expand_sse_pcmpestr, ix86_expand_sse_pcmpistr): Fix
+       spelling of error message.
+       * config/i386/sse.md (sse4a_extrqi, sse4a_insertqi,
+       vcvtps2ph, *vcvtps2ph, *vcvtps2ph_store, vcvtps2ph256): Use
+       const_0_to_255_operand instead of const_int_operand.
+
+       Revert:
+       2011-05-09  Uros Bizjak  <ubizjak@gmail.com>
+
+       * config/i386/sse.md (blendbits): Remove mode attribute.
+       (<sse4_1>_blend<ssemodesuffix><avxsizesuffix>): Use const_int_operand
+       instead of const_0_to_<blendbits>_operand for operand 3 predicate.
+       Check integer value of operand 3 in insn constraint.
+
 2011-06-17  Hans-Peter Nilsson  <hp@axis.com>
 
        PR rtl-optimization/48542
index 8d0b6b6..6029010 100644 (file)
@@ -25566,16 +25566,61 @@ ix86_expand_multi_arg_builtin (enum insn_code icode, tree exp, rtx target,
       int adjust = (comparison_p) ? 1 : 0;
       enum machine_mode mode = insn_data[icode].operand[i+adjust+1].mode;
 
-      if (last_arg_constant && i == nargs-1)
+      if (last_arg_constant && i == nargs - 1)
        {
-         if (!CONST_INT_P (op))
+         if (!insn_data[icode].operand[i + 1].predicate (op, mode))
            {
-             error ("last argument must be an immediate");
-             return gen_reg_rtx (tmode);
+             enum insn_code new_icode = icode;
+             switch (icode)
+               {
+               case CODE_FOR_xop_vpermil2v2df3:
+               case CODE_FOR_xop_vpermil2v4sf3:
+               case CODE_FOR_xop_vpermil2v4df3:
+               case CODE_FOR_xop_vpermil2v8sf3:
+                 error ("the last argument must be a 2-bit immediate");
+                 return gen_reg_rtx (tmode);
+               case CODE_FOR_xop_rotlv2di3:
+                 new_icode = CODE_FOR_rotlv2di3;
+                 goto xop_rotl;
+               case CODE_FOR_xop_rotlv4si3:
+                 new_icode = CODE_FOR_rotlv4si3;
+                 goto xop_rotl;
+               case CODE_FOR_xop_rotlv8hi3:
+                 new_icode = CODE_FOR_rotlv8hi3;
+                 goto xop_rotl;
+               case CODE_FOR_xop_rotlv16qi3:
+                 new_icode = CODE_FOR_rotlv16qi3;
+               xop_rotl:
+                 if (CONST_INT_P (op))
+                   {
+                     int mask = GET_MODE_BITSIZE (GET_MODE_INNER (tmode)) - 1;
+                     op = GEN_INT (INTVAL (op) & mask);
+                     gcc_checking_assert
+                       (insn_data[icode].operand[i + 1].predicate (op, mode));
+                   }
+                 else
+                   {
+                     gcc_checking_assert
+                       (nargs == 2
+                        && insn_data[new_icode].operand[0].mode == tmode
+                        && insn_data[new_icode].operand[1].mode == tmode
+                        && insn_data[new_icode].operand[2].mode == mode
+                        && insn_data[new_icode].operand[0].predicate
+                           == insn_data[icode].operand[0].predicate
+                        && insn_data[new_icode].operand[1].predicate
+                           == insn_data[icode].operand[1].predicate);
+                     icode = new_icode;
+                     goto non_constant;
+                   }
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
            }
        }
       else
        {
+       non_constant:
          if (VECTOR_MODE_P (mode))
            op = safe_vector_operand (op, mode);
 
@@ -25900,7 +25945,7 @@ ix86_expand_sse_pcmpestr (const struct builtin_description *d,
 
   if (!insn_data[d->icode].operand[6].predicate (op4, modeimm))
     {
-      error ("the fifth argument must be a 8-bit immediate");
+      error ("the fifth argument must be an 8-bit immediate");
       return const0_rtx;
     }
 
@@ -25995,7 +26040,7 @@ ix86_expand_sse_pcmpistr (const struct builtin_description *d,
 
   if (!insn_data[d->icode].operand[4].predicate (op2, modeimm))
     {
-      error ("the third argument must be a 8-bit immediate");
+      error ("the third argument must be an 8-bit immediate");
       return const0_rtx;
     }
 
index 9ede770..7abee33 100644 (file)
 
 (define_mode_iterator FMAMODE [SF DF V4SF V2DF V8SF V4DF])
 
+;; Mapping of immediate bits for blend instructions
+(define_mode_attr blendbits
+  [(V8SF "255") (V4SF "15") (V4DF "15") (V2DF "3")])
+
 ;; Patterns whose name begins with "sse{,2,3}_" are invoked by intrinsics.
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (define_insn "sse4a_extrqi"
   [(set (match_operand:V2DI 0 "register_operand" "=x")
         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
-                      (match_operand 2 "const_int_operand" "")
-                      (match_operand 3 "const_int_operand" "")]
+                      (match_operand 2 "const_0_to_255_operand" "")
+                      (match_operand 3 "const_0_to_255_operand" "")]
                      UNSPEC_EXTRQI))]
   "TARGET_SSE4A"
   "extrq\t{%3, %2, %0|%0, %2, %3}"
   [(set (match_operand:V2DI 0 "register_operand" "=x")
         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
                      (match_operand:V2DI 2 "register_operand" "x")
-                      (match_operand 3 "const_int_operand" "")
-                      (match_operand 4 "const_int_operand" "")]
+                      (match_operand 3 "const_0_to_255_operand" "")
+                      (match_operand 4 "const_0_to_255_operand" "")]
                      UNSPEC_INSERTQI))]
   "TARGET_SSE4A"
   "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
        (vec_merge:VF
          (match_operand:VF 2 "nonimmediate_operand" "xm,xm")
          (match_operand:VF 1 "register_operand" "0,x")
-         (match_operand:SI 3 "const_int_operand" "")))]
-  "TARGET_SSE4_1
-   && IN_RANGE (INTVAL (operands[3]), 0, (1 << GET_MODE_NUNITS (<MODE>mode))-1)"
+         (match_operand:SI 3 "const_0_to_<blendbits>_operand" "")))]
+  "TARGET_SSE4_1"
   "@
    blend<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
    vblend<ssemodesuffix>\t{%3, %2, %1, %0|%0, %1, %2, %3}"
   [(set (match_operand:V8HI 0 "register_operand" "")
        (vec_concat:V8HI
          (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "")
-                       (match_operand:SI 2 "immediate_operand" "")]
+                       (match_operand:SI 2 "const_0_to_255_operand" "")]
                       UNSPEC_VCVTPS2PH)
          (match_dup 3)))]
   "TARGET_F16C"
   [(set (match_operand:V8HI 0 "register_operand" "=x")
        (vec_concat:V8HI
          (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "x")
-                       (match_operand:SI 2 "immediate_operand" "N")]
+                       (match_operand:SI 2 "const_0_to_255_operand" "N")]
                       UNSPEC_VCVTPS2PH)
          (match_operand:V4HI 3 "const0_operand" "")))]
   "TARGET_F16C"
 (define_insn "*vcvtps2ph_store"
   [(set (match_operand:V4HI 0 "memory_operand" "=m")
        (unspec:V4HI [(match_operand:V4SF 1 "register_operand" "x")
-                     (match_operand:SI 2 "immediate_operand" "N")]
+                     (match_operand:SI 2 "const_0_to_255_operand" "N")]
                     UNSPEC_VCVTPS2PH))]
   "TARGET_F16C"
   "vcvtps2ph\t{%2, %1, %0|%0, %1, %2}"
 (define_insn "vcvtps2ph256"
   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=xm")
        (unspec:V8HI [(match_operand:V8SF 1 "register_operand" "x")
-                     (match_operand:SI 2 "immediate_operand" "N")]
+                     (match_operand:SI 2 "const_0_to_255_operand" "N")]
                     UNSPEC_VCVTPS2PH))]
   "TARGET_F16C"
   "vcvtps2ph\t{%2, %1, %0|%0, %1, %2}"
index d782641..dc35df3 100644 (file)
@@ -1,3 +1,18 @@
+2011-06-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/49411
+       * gcc.target/i386/testimm-1.c: New test.
+       * gcc.target/i386/testimm-2.c: New test.
+       * gcc.target/i386/testimm-3.c: New test.
+       * gcc.target/i386/testimm-4.c: New test.
+       * gcc.target/i386/testimm-5.c: New test.
+       * gcc.target/i386/testimm-6.c: New test.
+       * gcc.target/i386/testimm-7.c: New test.
+       * gcc.target/i386/testimm-8.c: New test.
+       * gcc.target/i386/xop-vpermil2px-2.c: New test.
+       * gcc.target/i386/xop-rotate1-int.c: New test.
+       * gcc.target/i386/xop-rotate2-int.c: New test.
+
 2011-06-17  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/rv-func2.C: New.
diff --git a/gcc/testsuite/gcc.target/i386/testimm-1.c b/gcc/testsuite/gcc.target/i386/testimm-1.c
new file mode 100644 (file)
index 0000000..5727619
--- /dev/null
@@ -0,0 +1,94 @@
+/* PR target/49411 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -mf16c -maes -mpclmul" } */
+
+#include <x86intrin.h>
+
+__m128i i1, i2, i3, i4;
+__m128 a1, a2, a3, a4;
+__m128d d1, d2, d3, d4;
+__m256i l1, l2, l3, l4;
+__m256 b1, b2, b3, b4;
+__m256d e1, e2, e3, e4;
+__m64 m1, m2, m3, m4;
+int k1, k2, k3, k4;
+float f1, f2, f3, f4;
+
+void
+test8bit (void)
+{
+  i1 = _mm_cmpistrm (i2, i3, 256);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistri (i2, i3, 256);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistra (i2, i3, 256);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrc (i2, i3, 256);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistro (i2, i3, 256);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrs (i2, i3, 256);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrz (i2, i3, 256);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  i1 = _mm_cmpestrm (i2, k2, i3, k3, 256);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestri (i2, k2, i3, k3, 256);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestra (i2, k2, i3, k3, 256);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrc (i2, k2, i3, k3, 256);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestro (i2, k2, i3, k3, 256);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrs (i2, k2, i3, k3, 256);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrz (i2, k2, i3, k3, 256);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  b1 = _mm256_blend_ps (b2, b3, 256);    /* { dg-error "the last argument must be an 8-bit immediate" } */
+  k1 = _cvtss_sh (f1, 256);              /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm256_cvtps_ph (b2, 256);        /* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_dp_ps (b2, b3, 256);       /* { dg-error "the last argument must be an 8-bit immediate" } */
+  e1 = _mm256_permute2f128_pd (e2, e3, 256);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_permute2f128_ps (b2, b3, 256);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  l1 = _mm256_permute2f128_si256 (l2, l3, 256);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_permute_ps (b2, 256);      /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_aeskeygenassist_si128 (i2, 256);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_blend_epi16 (i2, i3, 256);    /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_clmulepi64_si128 (i2, i3, 256);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_cvtps_ph (a1, 256);           /* { dg-error "the last argument must be an 8-bit immediate" } */
+  d1 = _mm_dp_pd (d2, d3, 256);                  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_dp_ps (a2, a3, 256);                  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_insert_ps (a2, a3, 256);      /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_mpsadbw_epu8 (i2, i3, 256);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_permute_ps (a2, 256);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_slli_si128 (i2, 256);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_srli_si128 (i2, 256);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
+
+void
+test5bit (void)
+{
+  d1 = _mm_cmp_sd (d2, d3, 32);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  a1 = _mm_cmp_ss (a2, a3, 32);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  d1 = _mm_cmp_pd (d2, d3, 32);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  a1 = _mm_cmp_ps (a2, a3, 32);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  e1 = _mm256_cmp_pd (e2, e3, 32);       /* { dg-error "the last argument must be a 5-bit immediate" } */
+  b1 = _mm256_cmp_ps (b2, b3, 32);       /* { dg-error "the last argument must be a 5-bit immediate" } */
+}
+
+void
+test4bit (void)
+{
+  d1 = _mm_round_pd (d2, 16);            /* { dg-error "the last argument must be a 4-bit immediate" } */
+  d1 = _mm_round_sd (d2, d3, 16);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_round_ps (a2, 16);            /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_round_ss (a2, a2, 16);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_blend_ps (a2, a3, 16);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  e1 = _mm256_blend_pd (e2, e3, 16);     /* { dg-error "the last argument must be a 4-bit immediate" } */
+  e1 = _mm256_round_pd (e2, 16);         /* { dg-error "the last argument must be a 4-bit immediate" } */
+  b1 = _mm256_round_ps (b2, 16);         /* { dg-error "the last argument must be a 4-bit immediate" } */
+}
+
+void
+test2bit (void)
+{
+  d1 = _mm_blend_pd (d2, d3, 4);         /* { dg-error "the last argument must be a 2-bit immediate" } */
+}
+
+void
+test1bit (void)
+{
+  d1 = _mm256_extractf128_pd (e2, 2);    /* { dg-error "the last argument must be a 1-bit immediate" } */
+  a1 = _mm256_extractf128_ps (b2, 2);    /* { dg-error "the last argument must be a 1-bit immediate" } */
+  i1 = _mm256_extractf128_si256 (l2, 2);  /* { dg-error "the last argument must be a 1-bit immediate" } */
+  e1 = _mm256_insertf128_pd (e2, d1, 2);  /* { dg-error "the last argument must be a 1-bit immediate" } */
+  b1 = _mm256_insertf128_ps (b2, a1, 2);  /* { dg-error "the last argument must be a 1-bit immediate" } */
+  l1 = _mm256_insertf128_si256 (l2, i1, 2);/* { dg-error "the last argument must be a 1-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/testimm-2.c b/gcc/testsuite/gcc.target/i386/testimm-2.c
new file mode 100644 (file)
index 0000000..3d50809
--- /dev/null
@@ -0,0 +1,94 @@
+/* PR target/49411 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -mf16c -maes -mpclmul" } */
+
+#include <x86intrin.h>
+
+__m128i i1, i2, i3, i4;
+__m128 a1, a2, a3, a4;
+__m128d d1, d2, d3, d4;
+__m256i l1, l2, l3, l4;
+__m256 b1, b2, b3, b4;
+__m256d e1, e2, e3, e4;
+__m64 m1, m2, m3, m4;
+int k1, k2, k3, k4;
+float f1, f2, f3, f4;
+
+void
+test8bit (void)
+{
+  i1 = _mm_cmpistrm (i2, i3, -10);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistri (i2, i3, -10);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistra (i2, i3, -10);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrc (i2, i3, -10);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistro (i2, i3, -10);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrs (i2, i3, -10);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrz (i2, i3, -10);       /* { dg-error "the third argument must be an 8-bit immediate" } */
+  i1 = _mm_cmpestrm (i2, k2, i3, k3, -10);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestri (i2, k2, i3, k3, -10);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestra (i2, k2, i3, k3, -10);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrc (i2, k2, i3, k3, -10);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestro (i2, k2, i3, k3, -10);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrs (i2, k2, i3, k3, -10);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrz (i2, k2, i3, k3, -10);/* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  b1 = _mm256_blend_ps (b2, b3, -10);    /* { dg-error "the last argument must be an 8-bit immediate" } */
+  k1 = _cvtss_sh (f1, -10);              /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm256_cvtps_ph (b2, -10);        /* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_dp_ps (b2, b3, -10);       /* { dg-error "the last argument must be an 8-bit immediate" } */
+  e1 = _mm256_permute2f128_pd (e2, e3, -10);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_permute2f128_ps (b2, b3, -10);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  l1 = _mm256_permute2f128_si256 (l2, l3, -10);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_permute_ps (b2, -10);      /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_aeskeygenassist_si128 (i2, -10);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_blend_epi16 (i2, i3, -10);    /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_clmulepi64_si128 (i2, i3, -10);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_cvtps_ph (a1, -10);           /* { dg-error "the last argument must be an 8-bit immediate" } */
+  d1 = _mm_dp_pd (d2, d3, -10);                  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_dp_ps (a2, a3, -10);                  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_insert_ps (a2, a3, -10);      /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_mpsadbw_epu8 (i2, i3, -10);   /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_permute_ps (a2, -10);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_slli_si128 (i2, -10);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_srli_si128 (i2, -10);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
+
+void
+test5bit (void)
+{
+  d1 = _mm_cmp_sd (d2, d3, -7);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  a1 = _mm_cmp_ss (a2, a3, -7);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  d1 = _mm_cmp_pd (d2, d3, -7);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  a1 = _mm_cmp_ps (a2, a3, -7);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  e1 = _mm256_cmp_pd (e2, e3, -7);       /* { dg-error "the last argument must be a 5-bit immediate" } */
+  b1 = _mm256_cmp_ps (b2, b3, -7);       /* { dg-error "the last argument must be a 5-bit immediate" } */
+}
+
+void
+test4bit (void)
+{
+  d1 = _mm_round_pd (d2, -7);            /* { dg-error "the last argument must be a 4-bit immediate" } */
+  d1 = _mm_round_sd (d2, d3, -7);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_round_ps (a2, -7);            /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_round_ss (a2, a2, -7);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_blend_ps (a2, a3, -7);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  e1 = _mm256_blend_pd (e2, e3, -7);     /* { dg-error "the last argument must be a 4-bit immediate" } */
+  e1 = _mm256_round_pd (e2, -7);         /* { dg-error "the last argument must be a 4-bit immediate" } */
+  b1 = _mm256_round_ps (b2, -7);         /* { dg-error "the last argument must be a 4-bit immediate" } */
+}
+
+void
+test2bit (void)
+{
+  d1 = _mm_blend_pd (d2, d3, -1);        /* { dg-error "the last argument must be a 2-bit immediate" } */
+}
+
+void
+test1bit (void)
+{
+  d1 = _mm256_extractf128_pd (e2, -1);   /* { dg-error "the last argument must be a 1-bit immediate" } */
+  a1 = _mm256_extractf128_ps (b2, -1);   /* { dg-error "the last argument must be a 1-bit immediate" } */
+  i1 = _mm256_extractf128_si256 (l2, -1); /* { dg-error "the last argument must be a 1-bit immediate" } */
+  e1 = _mm256_insertf128_pd (e2, d1, -1); /* { dg-error "the last argument must be a 1-bit immediate" } */
+  b1 = _mm256_insertf128_ps (b2, a1, -1); /* { dg-error "the last argument must be a 1-bit immediate" } */
+  l1 = _mm256_insertf128_si256 (l2, i1, -1);/* { dg-error "the last argument must be a 1-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/testimm-3.c b/gcc/testsuite/gcc.target/i386/testimm-3.c
new file mode 100644 (file)
index 0000000..3e4fea7
--- /dev/null
@@ -0,0 +1,94 @@
+/* PR target/49411 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -mf16c -maes -mpclmul" } */
+
+#include <x86intrin.h>
+
+__m128i i1, i2, i3, i4;
+__m128 a1, a2, a3, a4;
+__m128d d1, d2, d3, d4;
+__m256i l1, l2, l3, l4;
+__m256 b1, b2, b3, b4;
+__m256d e1, e2, e3, e4;
+__m64 m1, m2, m3, m4;
+int k1, k2, k3, k4;
+float f1, f2, f3, f4;
+
+void
+test8bit (void)
+{
+  i1 = _mm_cmpistrm (i2, i3, k4);        /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistri (i2, i3, k4);        /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistra (i2, i3, k4);        /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrc (i2, i3, k4);        /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistro (i2, i3, k4);        /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrs (i2, i3, k4);        /* { dg-error "the third argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpistrz (i2, i3, k4);        /* { dg-error "the third argument must be an 8-bit immediate" } */
+  i1 = _mm_cmpestrm (i2, k2, i3, k3, k4); /* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestri (i2, k2, i3, k3, k4); /* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestra (i2, k2, i3, k3, k4); /* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrc (i2, k2, i3, k3, k4); /* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestro (i2, k2, i3, k3, k4); /* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrs (i2, k2, i3, k3, k4); /* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  k1 = _mm_cmpestrz (i2, k2, i3, k3, k4); /* { dg-error "the fifth argument must be an 8-bit immediate" } */
+  b1 = _mm256_blend_ps (b2, b3, k4);     /* { dg-error "the last argument must be an 8-bit immediate" } */
+  k1 = _cvtss_sh (f1, k4);               /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm256_cvtps_ph (b2, k4);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_dp_ps (b2, b3, k4);        /* { dg-error "the last argument must be an 8-bit immediate" } */
+  e1 = _mm256_permute2f128_pd (e2, e3, k4);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_permute2f128_ps (b2, b3, k4);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  l1 = _mm256_permute2f128_si256 (l2, l3, k4);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  b1 = _mm256_permute_ps (b2, k4);       /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_aeskeygenassist_si128 (i2, k4);/* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_blend_epi16 (i2, i3, k4);     /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_clmulepi64_si128 (i2, i3, k4); /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_cvtps_ph (a1, k4);            /* { dg-error "the last argument must be an 8-bit immediate" } */
+  d1 = _mm_dp_pd (d2, d3, k4);           /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_dp_ps (a2, a3, k4);           /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_insert_ps (a2, a3, k4);       /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_mpsadbw_epu8 (i2, i3, k4);    /* { dg-error "the last argument must be an 8-bit immediate" } */
+  a1 = _mm_permute_ps (a2, k4);                  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_slli_si128 (i2, k4);                  /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_srli_si128 (i2, k4);                  /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
+
+void
+test5bit (void)
+{
+  d1 = _mm_cmp_sd (d2, d3, k4);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  a1 = _mm_cmp_ss (a2, a3, k4);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  d1 = _mm_cmp_pd (d2, d3, k4);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  a1 = _mm_cmp_ps (a2, a3, k4);                  /* { dg-error "the last argument must be a 5-bit immediate" } */
+  e1 = _mm256_cmp_pd (e2, e3, k4);       /* { dg-error "the last argument must be a 5-bit immediate" } */
+  b1 = _mm256_cmp_ps (b2, b3, k4);       /* { dg-error "the last argument must be a 5-bit immediate" } */
+}
+
+void
+test4bit (void)
+{
+  d1 = _mm_round_pd (d2, k4);            /* { dg-error "the last argument must be a 4-bit immediate" } */
+  d1 = _mm_round_sd (d2, d3, k4);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_round_ps (a2, k4);            /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_round_ss (a2, a2, k4);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  a1 = _mm_blend_ps (a2, a3, k4);        /* { dg-error "the last argument must be a 4-bit immediate" } */
+  e1 = _mm256_blend_pd (e2, e3, k4);     /* { dg-error "the last argument must be a 4-bit immediate" } */
+  e1 = _mm256_round_pd (e2, k4);         /* { dg-error "the last argument must be a 4-bit immediate" } */
+  b1 = _mm256_round_ps (b2, k4);         /* { dg-error "the last argument must be a 4-bit immediate" } */
+}
+
+void
+test2bit (void)
+{
+  d1 = _mm_blend_pd (d2, d3, k4);        /* { dg-error "the last argument must be a 2-bit immediate" } */
+}
+
+void
+test1bit (void)
+{
+  d1 = _mm256_extractf128_pd (e2, k4);   /* { dg-error "the last argument must be a 1-bit immediate" } */
+  a1 = _mm256_extractf128_ps (b2, k4);   /* { dg-error "the last argument must be a 1-bit immediate" } */
+  i1 = _mm256_extractf128_si256 (l2, k4); /* { dg-error "the last argument must be a 1-bit immediate" } */
+  e1 = _mm256_insertf128_pd (e2, d1, k4); /* { dg-error "the last argument must be a 1-bit immediate" } */
+  b1 = _mm256_insertf128_ps (b2, a1, k4); /* { dg-error "the last argument must be a 1-bit immediate" } */
+  l1 = _mm256_insertf128_si256 (l2, i1, k4);/* { dg-error "the last argument must be a 1-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/testimm-4.c b/gcc/testsuite/gcc.target/i386/testimm-4.c
new file mode 100644 (file)
index 0000000..2eaf413
--- /dev/null
@@ -0,0 +1,97 @@
+/* PR target/49411 */
+/* { dg-do assemble } */
+/* { dg-options "-O0 -mf16c -maes -mpclmul" } */
+/* { dg-require-effective-target f16c } */
+/* { dg-require-effective-target vaes } */
+/* { dg-require-effective-target vpclmul } */
+
+#include <x86intrin.h>
+
+__m128i i1, i2, i3, i4;
+__m128 a1, a2, a3, a4;
+__m128d d1, d2, d3, d4;
+__m256i l1, l2, l3, l4;
+__m256 b1, b2, b3, b4;
+__m256d e1, e2, e3, e4;
+__m64 m1, m2, m3, m4;
+int k1, k2, k3, k4;
+float f1, f2, f3, f4;
+
+void
+test8bit (void)
+{
+  i1 = _mm_cmpistrm (i2, i3, 255);
+  k1 = _mm_cmpistri (i2, i3, 255);
+  k1 = _mm_cmpistra (i2, i3, 255);
+  k1 = _mm_cmpistrc (i2, i3, 255);
+  k1 = _mm_cmpistro (i2, i3, 255);
+  k1 = _mm_cmpistrs (i2, i3, 255);
+  k1 = _mm_cmpistrz (i2, i3, 255);
+  i1 = _mm_cmpestrm (i2, k2, i3, k3, 255);
+  k1 = _mm_cmpestri (i2, k2, i3, k3, 255);
+  k1 = _mm_cmpestra (i2, k2, i3, k3, 255);
+  k1 = _mm_cmpestrc (i2, k2, i3, k3, 255);
+  k1 = _mm_cmpestro (i2, k2, i3, k3, 255);
+  k1 = _mm_cmpestrs (i2, k2, i3, k3, 255);
+  k1 = _mm_cmpestrz (i2, k2, i3, k3, 255);
+  b1 = _mm256_blend_ps (b2, b3, 255);
+  k1 = _cvtss_sh (f1, 255);
+  i1 = _mm256_cvtps_ph (b2, 255);
+  b1 = _mm256_dp_ps (b2, b3, 255);
+  e1 = _mm256_permute2f128_pd (e2, e3, 255);
+  b1 = _mm256_permute2f128_ps (b2, b3, 255);
+  l1 = _mm256_permute2f128_si256 (l2, l3, 255);
+  b1 = _mm256_permute_ps (b2, 255);
+  i1 = _mm_aeskeygenassist_si128 (i2, 255);
+  i1 = _mm_blend_epi16 (i2, i3, 255);
+  i1 = _mm_clmulepi64_si128 (i2, i3, 255);
+  i1 = _mm_cvtps_ph (a1, 255);
+  d1 = _mm_dp_pd (d2, d3, 255);
+  a1 = _mm_dp_ps (a2, a3, 255);
+  a1 = _mm_insert_ps (a2, a3, 255);
+  i1 = _mm_mpsadbw_epu8 (i2, i3, 255);
+  a1 = _mm_permute_ps (a2, 255);
+  i1 = _mm_slli_si128 (i2, 255);
+  i1 = _mm_srli_si128 (i2, 255);
+}
+
+void
+test5bit (void)
+{
+  d1 = _mm_cmp_sd (d2, d3, 31);
+  a1 = _mm_cmp_ss (a2, a3, 31);
+  d1 = _mm_cmp_pd (d2, d3, 31);
+  a1 = _mm_cmp_ps (a2, a3, 31);
+  e1 = _mm256_cmp_pd (e2, e3, 31);
+  b1 = _mm256_cmp_ps (b2, b3, 31);
+}
+
+void
+test4bit (void)
+{
+  d1 = _mm_round_pd (d2, 15);
+  d1 = _mm_round_sd (d2, d3, 15);
+  a1 = _mm_round_ps (a2, 15);
+  a1 = _mm_round_ss (a2, a2, 15);
+  a1 = _mm_blend_ps (a2, a3, 15);
+  e1 = _mm256_blend_pd (e2, e3, 15);
+  e1 = _mm256_round_pd (e2, 15);
+  b1 = _mm256_round_ps (b2, 15);
+}
+
+void
+test2bit (void)
+{
+  d1 = _mm_blend_pd (d2, d3, 3);
+}
+
+void
+test1bit (void)
+{
+  d1 = _mm256_extractf128_pd (e2, 1);
+  a1 = _mm256_extractf128_ps (b2, 1);
+  i1 = _mm256_extractf128_si256 (l2, 1);
+  e1 = _mm256_insertf128_pd (e2, d1, 1);
+  b1 = _mm256_insertf128_ps (b2, a1, 1);
+  l1 = _mm256_insertf128_si256 (l2, i1, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/testimm-5.c b/gcc/testsuite/gcc.target/i386/testimm-5.c
new file mode 100644 (file)
index 0000000..67c1528
--- /dev/null
@@ -0,0 +1,8 @@
+/* PR target/49411 */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -mf16c -maes -mpclmul" } */
+/* { dg-require-effective-target f16c } */
+/* { dg-require-effective-target vaes } */
+/* { dg-require-effective-target vpclmul } */
+
+#include "testimm-4.c"
diff --git a/gcc/testsuite/gcc.target/i386/testimm-6.c b/gcc/testsuite/gcc.target/i386/testimm-6.c
new file mode 100644 (file)
index 0000000..087a6ff
--- /dev/null
@@ -0,0 +1,41 @@
+/* PR target/49411 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -mxop" } */
+
+#include <x86intrin.h>
+
+__m128i i1, i2, i3, i4;
+__m128 a1, a2, a3, a4;
+__m128d d1, d2, d3, d4;
+__m256i l1, l2, l3, l4;
+__m256 b1, b2, b3, b4;
+__m256d e1, e2, e3, e4;
+__m64 m1, m2, m3, m4;
+int k1, k2, k3, k4;
+float f1, f2, f3, f4;
+
+void
+test2bit (void)
+{
+  d1 = _mm_permute2_pd (d2, d3, i1, 17);       /* { dg-error "the last argument must be a 2-bit immediate" } */
+  e1 = _mm256_permute2_pd (e2, e3, l1, 17);    /* { dg-error "the last argument must be a 2-bit immediate" } */
+  a1 = _mm_permute2_ps (a2, a3, i1, 17);       /* { dg-error "the last argument must be a 2-bit immediate" } */
+  b1 = _mm256_permute2_ps (b2, b3, l1, 17);    /* { dg-error "the last argument must be a 2-bit immediate" } */
+  d1 = _mm_permute2_pd (d2, d3, i1, k4);       /* { dg-error "the last argument must be a 2-bit immediate" } */
+  e1 = _mm256_permute2_pd (e2, e3, l1, k4);    /* { dg-error "the last argument must be a 2-bit immediate" } */
+  a1 = _mm_permute2_ps (a2, a3, i1, k4);       /* { dg-error "the last argument must be a 2-bit immediate" } */
+  b1 = _mm256_permute2_ps (b2, b3, l1, k4);    /* { dg-error "the last argument must be a 2-bit immediate" } */
+}
+
+void
+test2args (void)
+{
+  i1 = _mm_extracti_si64 (i2, 256, 0);         /* { dg-error "the next to last argument must be an 8-bit immediate" } */
+  i1 = _mm_extracti_si64 (i2, 0, 256);         /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_inserti_si64 (i2, i3, 256, 0);      /* { dg-error "the next to last argument must be an 8-bit immediate" } */
+  i2 = _mm_inserti_si64 (i2, i3, 0, 256);      /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_extracti_si64 (i2, k4, 0);          /* { dg-error "the next to last argument must be an 8-bit immediate" } */
+  i1 = _mm_extracti_si64 (i2, 0, k4);          /* { dg-error "the last argument must be an 8-bit immediate" } */
+  i1 = _mm_inserti_si64 (i2, i3, k4, 0);       /* { dg-error "the next to last argument must be an 8-bit immediate" } */
+  i2 = _mm_inserti_si64 (i2, i3, 0, k4);       /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
diff --git a/gcc/testsuite/gcc.target/i386/testimm-7.c b/gcc/testsuite/gcc.target/i386/testimm-7.c
new file mode 100644 (file)
index 0000000..9b16fc7
--- /dev/null
@@ -0,0 +1,46 @@
+/* PR target/49411 */
+/* { dg-do assemble } */
+/* { dg-options "-O0 -mxop" } */
+/* { dg-require-effective-target xop } */
+
+#include <x86intrin.h>
+
+__m128i i1, i2, i3, i4;
+__m128 a1, a2, a3, a4;
+__m128d d1, d2, d3, d4;
+__m256i l1, l2, l3, l4;
+__m256 b1, b2, b3, b4;
+__m256d e1, e2, e3, e4;
+__m64 m1, m2, m3, m4;
+int k1, k2, k3, k4;
+float f1, f2, f3, f4;
+
+void
+test2bit (void)
+{
+  d1 = _mm_permute2_pd (d2, d3, i1, 3);
+  e1 = _mm256_permute2_pd (e2, e3, l1, 3);
+  a1 = _mm_permute2_ps (a2, a3, i1, 3);
+  b1 = _mm256_permute2_ps (b2, b3, l1, 3);
+  d1 = _mm_permute2_pd (d2, d3, i1, 0);
+  e1 = _mm256_permute2_pd (e2, e3, l1, 0);
+  a1 = _mm_permute2_ps (a2, a3, i1, 0);
+  b1 = _mm256_permute2_ps (b2, b3, l1, 0);
+}
+
+void
+test2args (void)
+{
+  i1 = _mm_extracti_si64 (i2, 255, 0);
+  i1 = _mm_extracti_si64 (i2, 0, 255);
+  i1 = _mm_inserti_si64 (i2, i3, 255, 0);
+  i2 = _mm_inserti_si64 (i2, i3, 0, 255);
+  i1 = _mm_extracti_si64 (i2, 255, 255);
+  i1 = _mm_extracti_si64 (i2, 255, 255);
+  i1 = _mm_inserti_si64 (i2, i3, 255, 255);
+  i2 = _mm_inserti_si64 (i2, i3, 255, 255);
+  i1 = _mm_extracti_si64 (i2, 0, 0);
+  i1 = _mm_extracti_si64 (i2, 0, 0);
+  i1 = _mm_inserti_si64 (i2, i3, 0, 0);
+  i2 = _mm_inserti_si64 (i2, i3, 0, 0);
+}
diff --git a/gcc/testsuite/gcc.target/i386/testimm-8.c b/gcc/testsuite/gcc.target/i386/testimm-8.c
new file mode 100644 (file)
index 0000000..5169763
--- /dev/null
@@ -0,0 +1,6 @@
+/* PR target/49411 */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -mxop" } */
+/* { dg-require-effective-target xop } */
+
+#include "testimm-7.c"
diff --git a/gcc/testsuite/gcc.target/i386/xop-rotate1-int.c b/gcc/testsuite/gcc.target/i386/xop-rotate1-int.c
new file mode 100644 (file)
index 0000000..a58cd72
--- /dev/null
@@ -0,0 +1,63 @@
+/* PR target/49411 */
+/* { dg-do run } */
+/* { dg-require-effective-target xop } */
+/* { dg-options "-O2 -mxop" } */
+
+#include "xop-check.h"
+
+#include <x86intrin.h>
+
+extern void abort (void);
+
+union
+{
+  __m128i v;
+  unsigned char c[16];
+  unsigned short s[8];
+  unsigned int i[4];
+  unsigned long long l[2];
+} a, b, c, d;
+
+#define TEST1(F, N, S, SS) \
+do {                                                   \
+  for (i = 0; i < sizeof (a.F) / sizeof (a.F[0]); i++) \
+    a.F[i] = i * 17;                                   \
+  s = _mm_set1_epi##SS (N);                            \
+  b.v = _mm_roti_epi##S (a.v, N);                      \
+  c.v = _mm_rot_epi##S (a.v, s);                       \
+  for (i = 0; i < sizeof (a.F) / sizeof (a.F[0]); i++) \
+    {                                                  \
+      int mask = __CHAR_BIT__ * sizeof (a.F[i]) - 1;   \
+      d.F[i] = a.F[i] << (N & mask);                   \
+      if (N & mask)                                    \
+       d.F[i] |= a.F[i] >> (mask + 1 - (N & mask));    \
+      if (b.F[i] != c.F[i] || b.F[i] != d.F[i])                \
+       abort ();                                       \
+    }                                                  \
+} while (0)
+#define TEST(N) \
+  TEST1 (c, N, 8, 8);                                  \
+  TEST1 (s, N, 16, 16);                                        \
+  TEST1 (i, N, 32, 32);                                        \
+  TEST1 (l, N, 64, 64x)
+
+volatile int n;
+
+static void
+xop_test (void)
+{
+  unsigned int i;
+  __m128i s;
+
+#ifndef NON_CONST
+  TEST (5);
+  TEST (-5);
+  TEST (0);
+  TEST (31);
+#else
+  n = 5; TEST (n);
+  n = -5; TEST (n);
+  n = 0; TEST (n);
+  n = 31; TEST (n);
+#endif
+}
diff --git a/gcc/testsuite/gcc.target/i386/xop-rotate2-int.c b/gcc/testsuite/gcc.target/i386/xop-rotate2-int.c
new file mode 100644 (file)
index 0000000..634a51a
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR target/49411 */
+/* { dg-do run } */
+/* { dg-require-effective-target xop } */
+/* { dg-options "-O2 -mxop" } */
+
+#define NON_CONST 1
+#include "xop-rotate1-int.c"