AVX-512. Add vpshuf[lh]w insn patterns.
authorAlexander Ivchenko <alexander.ivchenko@intel.com>
Wed, 24 Sep 2014 08:05:17 +0000 (08:05 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Wed, 24 Sep 2014 08:05:17 +0000 (08:05 +0000)
gcc/
* config/i386/sse.md
(define_c_enum "unspec"): Add UNSPEC_PSHUFHW, UNSPEC_PSHUFLW.
(define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"): New.
(define_expand "avx512vl_pshuflwv3_mask"): Ditto.
(define_insn "avx2_pshuflw_1<mask_name>"): Add masking.
(define_expand "avx512vl_pshuflw_mask"): New.
(define_insn "sse2_pshuflw_1<mask_name>"): Add masking.
(define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"): New.
(define_expand "avx512vl_pshufhwv3_mask"): Ditto.
(define_insn "avx2_pshufhw_1<mask_name>"): Add masking.
(define_expand "avx512vl_pshufhw_mask"): New.
(define_insn "sse2_pshufhw_1<mask_name>"): Add masking.

Co-Authored-By: Andrey Turetskiy <andrey.turetskiy@intel.com>
Co-Authored-By: Anna Tikhonova <anna.tikhonova@intel.com>
Co-Authored-By: Ilya Tocar <ilya.tocar@intel.com>
Co-Authored-By: Ilya Verbin <ilya.verbin@intel.com>
Co-Authored-By: Kirill Yukhin <kirill.yukhin@intel.com>
Co-Authored-By: Maxim Kuznetsov <maxim.kuznetsov@intel.com>
Co-Authored-By: Michael Zolotukhin <michael.v.zolotukhin@intel.com>
From-SVN: r215544

gcc/ChangeLog
gcc/config/i386/sse.md

index 6fd0bf9e0b511ca6dae4c890f03ed51cbaee8bbc..a9707a3b8ac650cf4879a106ddc0083ff4543a2d 100644 (file)
@@ -1,3 +1,25 @@
+2014-09-24  Alexander Ivchenko  <alexander.ivchenko@intel.com>
+           Maxim Kuznetsov  <maxim.kuznetsov@intel.com>
+           Anna Tikhonova  <anna.tikhonova@intel.com>
+           Ilya Tocar  <ilya.tocar@intel.com>
+           Andrey Turetskiy  <andrey.turetskiy@intel.com>
+           Ilya Verbin  <ilya.verbin@intel.com>
+           Kirill Yukhin  <kirill.yukhin@intel.com>
+           Michael Zolotukhin  <michael.v.zolotukhin@intel.com>
+
+       * config/i386/sse.md
+       (define_c_enum "unspec"): Add UNSPEC_PSHUFHW, UNSPEC_PSHUFLW.
+       (define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"): New.
+       (define_expand "avx512vl_pshuflwv3_mask"): Ditto.
+       (define_insn "avx2_pshuflw_1<mask_name>"): Add masking.
+       (define_expand "avx512vl_pshuflw_mask"): New.
+       (define_insn "sse2_pshuflw_1<mask_name>"): Add masking.
+       (define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"): New.
+       (define_expand "avx512vl_pshufhwv3_mask"): Ditto.
+       (define_insn "avx2_pshufhw_1<mask_name>"): Add masking.
+       (define_expand "avx512vl_pshufhw_mask"): New.
+       (define_insn "sse2_pshufhw_1<mask_name>"): Add masking.
+
 2014-09-24  Alexander Ivchenko  <alexander.ivchenko@intel.com>
            Maxim Kuznetsov  <maxim.kuznetsov@intel.com>
            Anna Tikhonova  <anna.tikhonova@intel.com>
index dddf16d7ec5240b098d961e5d24f0238bcfb665f..d1c399c57557e88c9ee3bedddf9b86671f13181c 100644 (file)
   UNSPEC_SHA256MSG2
   UNSPEC_SHA256RNDS2
 
+  ;; For AVX512BW support
+  UNSPEC_PSHUFHW
+  UNSPEC_PSHUFLW
+
   ;; For AVX512DQ support
   UNSPEC_REDUCE
   UNSPEC_FPCLASS
    (set_attr "length_immediate" "1")
    (set_attr "mode" "TI")])
 
+(define_insn "<mask_codefor>avx512bw_pshuflwv32hi<mask_name>"
+  [(set (match_operand:V32HI 0 "register_operand" "=v")
+       (unspec:V32HI
+         [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
+          (match_operand:SI 2 "const_0_to_255_operand" "n")]
+         UNSPEC_PSHUFLW))]
+  "TARGET_AVX512BW"
+  "vpshuflw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
+  [(set_attr "type" "sselog")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "XI")])
+
+(define_expand "avx512vl_pshuflwv3_mask"
+  [(match_operand:V16HI 0 "register_operand")
+   (match_operand:V16HI 1 "nonimmediate_operand")
+   (match_operand:SI 2 "const_0_to_255_operand")
+   (match_operand:V16HI 3 "register_operand")
+   (match_operand:HI 4 "register_operand")]
+  "TARGET_AVX512VL && TARGET_AVX512BW"
+{
+  int mask = INTVAL (operands[2]);
+  emit_insn (gen_avx2_pshuflw_1_mask (operands[0], operands[1],
+                                GEN_INT ((mask >> 0) & 3),
+                                GEN_INT ((mask >> 2) & 3),
+                                GEN_INT ((mask >> 4) & 3),
+                                GEN_INT ((mask >> 6) & 3),
+                                GEN_INT (((mask >> 0) & 3) + 8),
+                                GEN_INT (((mask >> 2) & 3) + 8),
+                                GEN_INT (((mask >> 4) & 3) + 8),
+                                GEN_INT (((mask >> 6) & 3) + 8),
+                 operands[3], operands[4]));
+  DONE;
+})
+
 (define_expand "avx2_pshuflwv3"
   [(match_operand:V16HI 0 "register_operand")
    (match_operand:V16HI 1 "nonimmediate_operand")
   DONE;
 })
 
-(define_insn "avx2_pshuflw_1"
-  [(set (match_operand:V16HI 0 "register_operand" "=x")
+(define_insn "avx2_pshuflw_1<mask_name>"
+  [(set (match_operand:V16HI 0 "register_operand" "=v")
        (vec_select:V16HI
-         (match_operand:V16HI 1 "nonimmediate_operand" "xm")
+         (match_operand:V16HI 1 "nonimmediate_operand" "vm")
          (parallel [(match_operand 2 "const_0_to_3_operand")
                     (match_operand 3 "const_0_to_3_operand")
                     (match_operand 4 "const_0_to_3_operand")
                     (const_int 14)
                     (const_int 15)])))]
   "TARGET_AVX2
+   && <mask_avx512bw_condition> && <mask_avx512vl_condition>
    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
   mask |= INTVAL (operands[5]) << 6;
   operands[2] = GEN_INT (mask);
 
-  return "vpshuflw\t{%2, %1, %0|%0, %1, %2}";
+  return "vpshuflw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
 }
   [(set_attr "type" "sselog")
-   (set_attr "prefix" "vex")
+   (set_attr "prefix" "maybe_evex")
    (set_attr "length_immediate" "1")
    (set_attr "mode" "OI")])
 
+(define_expand "avx512vl_pshuflw_mask"
+  [(match_operand:V8HI 0 "register_operand")
+   (match_operand:V8HI 1 "nonimmediate_operand")
+   (match_operand:SI 2 "const_0_to_255_operand")
+   (match_operand:V8HI 3 "register_operand")
+   (match_operand:QI 4 "register_operand")]
+  "TARGET_AVX512VL && TARGET_AVX512BW"
+{
+  int mask = INTVAL (operands[2]);
+  emit_insn (gen_sse2_pshuflw_1_mask (operands[0], operands[1],
+                                GEN_INT ((mask >> 0) & 3),
+                                GEN_INT ((mask >> 2) & 3),
+                                GEN_INT ((mask >> 4) & 3),
+                                GEN_INT ((mask >> 6) & 3),
+                 operands[3], operands[4]));
+  DONE;
+})
+
 (define_expand "sse2_pshuflw"
   [(match_operand:V8HI 0 "register_operand")
    (match_operand:V8HI 1 "nonimmediate_operand")
   DONE;
 })
 
-(define_insn "sse2_pshuflw_1"
-  [(set (match_operand:V8HI 0 "register_operand" "=x")
+(define_insn "sse2_pshuflw_1<mask_name>"
+  [(set (match_operand:V8HI 0 "register_operand" "=v")
        (vec_select:V8HI
-         (match_operand:V8HI 1 "nonimmediate_operand" "xm")
+         (match_operand:V8HI 1 "nonimmediate_operand" "vm")
          (parallel [(match_operand 2 "const_0_to_3_operand")
                     (match_operand 3 "const_0_to_3_operand")
                     (match_operand 4 "const_0_to_3_operand")
                     (const_int 5)
                     (const_int 6)
                     (const_int 7)])))]
-  "TARGET_SSE2"
+  "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
 {
   int mask = 0;
   mask |= INTVAL (operands[2]) << 0;
   mask |= INTVAL (operands[5]) << 6;
   operands[2] = GEN_INT (mask);
 
-  return "%vpshuflw\t{%2, %1, %0|%0, %1, %2}";
+  return "%vpshuflw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
 }
   [(set_attr "type" "sselog")
    (set_attr "prefix_data16" "0")
   DONE;
 })
 
-(define_insn "avx2_pshufhw_1"
-  [(set (match_operand:V16HI 0 "register_operand" "=x")
+(define_insn "<mask_codefor>avx512bw_pshufhwv32hi<mask_name>"
+  [(set (match_operand:V32HI 0 "register_operand" "=v")
+       (unspec:V32HI
+         [(match_operand:V32HI 1 "nonimmediate_operand" "vm")
+          (match_operand:SI 2 "const_0_to_255_operand" "n")]
+         UNSPEC_PSHUFHW))]
+  "TARGET_AVX512BW"
+  "vpshufhw\t{%2, %1, %0<mask_operand3>|%0<mask_operand3>, %1, %2}"
+  [(set_attr "type" "sselog")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "XI")])
+
+(define_expand "avx512vl_pshufhwv3_mask"
+  [(match_operand:V16HI 0 "register_operand")
+   (match_operand:V16HI 1 "nonimmediate_operand")
+   (match_operand:SI 2 "const_0_to_255_operand")
+   (match_operand:V16HI 3 "register_operand")
+   (match_operand:HI 4 "register_operand")]
+  "TARGET_AVX512VL && TARGET_AVX512BW"
+{
+  int mask = INTVAL (operands[2]);
+  emit_insn (gen_avx2_pshufhw_1_mask (operands[0], operands[1],
+                                GEN_INT (((mask >> 0) & 3) + 4),
+                                GEN_INT (((mask >> 2) & 3) + 4),
+                                GEN_INT (((mask >> 4) & 3) + 4),
+                                GEN_INT (((mask >> 6) & 3) + 4),
+                                GEN_INT (((mask >> 0) & 3) + 12),
+                                GEN_INT (((mask >> 2) & 3) + 12),
+                                GEN_INT (((mask >> 4) & 3) + 12),
+                                GEN_INT (((mask >> 6) & 3) + 12),
+                 operands[3], operands[4]));
+  DONE;
+})
+
+(define_insn "avx2_pshufhw_1<mask_name>"
+  [(set (match_operand:V16HI 0 "register_operand" "=v")
        (vec_select:V16HI
-         (match_operand:V16HI 1 "nonimmediate_operand" "xm")
+         (match_operand:V16HI 1 "nonimmediate_operand" "vm")
          (parallel [(const_int 0)
                     (const_int 1)
                     (const_int 2)
                     (match_operand 8 "const_12_to_15_operand")
                     (match_operand 9 "const_12_to_15_operand")])))]
   "TARGET_AVX2
+   && <mask_avx512bw_condition> && <mask_avx512vl_condition>
    && INTVAL (operands[2]) + 8 == INTVAL (operands[6])
    && INTVAL (operands[3]) + 8 == INTVAL (operands[7])
    && INTVAL (operands[4]) + 8 == INTVAL (operands[8])
   mask |= (INTVAL (operands[5]) - 4) << 6;
   operands[2] = GEN_INT (mask);
 
-  return "vpshufhw\t{%2, %1, %0|%0, %1, %2}";
+  return "vpshufhw\t{%2, %1, %0<mask_operand10>|%0<mask_operand10>, %1, %2}";
 }
   [(set_attr "type" "sselog")
-   (set_attr "prefix" "vex")
+   (set_attr "prefix" "maybe_evex")
    (set_attr "length_immediate" "1")
    (set_attr "mode" "OI")])
 
+(define_expand "avx512vl_pshufhw_mask"
+  [(match_operand:V8HI 0 "register_operand")
+   (match_operand:V8HI 1 "nonimmediate_operand")
+   (match_operand:SI 2 "const_0_to_255_operand")
+   (match_operand:V8HI 3 "register_operand")
+   (match_operand:QI 4 "register_operand")]
+  "TARGET_AVX512VL && TARGET_AVX512BW"
+{
+  int mask = INTVAL (operands[2]);
+  emit_insn (gen_sse2_pshufhw_1_mask (operands[0], operands[1],
+                                GEN_INT (((mask >> 0) & 3) + 4),
+                                GEN_INT (((mask >> 2) & 3) + 4),
+                                GEN_INT (((mask >> 4) & 3) + 4),
+                                GEN_INT (((mask >> 6) & 3) + 4),
+                 operands[3], operands[4]));
+  DONE;
+})
+
 (define_expand "sse2_pshufhw"
   [(match_operand:V8HI 0 "register_operand")
    (match_operand:V8HI 1 "nonimmediate_operand")
   DONE;
 })
 
-(define_insn "sse2_pshufhw_1"
-  [(set (match_operand:V8HI 0 "register_operand" "=x")
+(define_insn "sse2_pshufhw_1<mask_name>"
+  [(set (match_operand:V8HI 0 "register_operand" "=v")
        (vec_select:V8HI
-         (match_operand:V8HI 1 "nonimmediate_operand" "xm")
+         (match_operand:V8HI 1 "nonimmediate_operand" "vm")
          (parallel [(const_int 0)
                     (const_int 1)
                     (const_int 2)
                     (match_operand 3 "const_4_to_7_operand")
                     (match_operand 4 "const_4_to_7_operand")
                     (match_operand 5 "const_4_to_7_operand")])))]
-  "TARGET_SSE2"
+  "TARGET_SSE2 && <mask_avx512bw_condition> && <mask_avx512vl_condition>"
 {
   int mask = 0;
   mask |= (INTVAL (operands[2]) - 4) << 0;
   mask |= (INTVAL (operands[5]) - 4) << 6;
   operands[2] = GEN_INT (mask);
 
-  return "%vpshufhw\t{%2, %1, %0|%0, %1, %2}";
+  return "%vpshufhw\t{%2, %1, %0<mask_operand6>|%0<mask_operand6>, %1, %2}";
 }
   [(set_attr "type" "sselog")
    (set_attr "prefix_rep" "1")