[RS6000] Migrate from reduc_xxx to reduc_xxx_scal optabs
authorAlan Lawrence <alan.lawrence@arm.com>
Mon, 21 Sep 2015 10:38:27 +0000 (10:38 +0000)
committerAlan Lawrence <alalaw01@gcc.gnu.org>
Mon, 21 Sep 2015 10:38:27 +0000 (10:38 +0000)
* config/rs6000/altivec.md (reduc_splus_<mode>): Rename to...
(reduc_plus_scal_<mode>): ...this, add rs6000_expand_vector_extract.
(reduc_uplus_v16qi): Remove.

* config/rs6000/vector.md (VEC_reduc_name): Change "splus" to "plus".
(reduc_<VEC_reduc_name>_v2df): Remove.
(reduc_<VEC_reduc_name>_v4sf): Remove.
(reduc_<VEC_reduc:VEC_reduc_name>_scal_<VEC_F:name>): New.

* config/rs6000/vsx.md (vsx_reduc_<VEC_reduc_name>_v2df): Declare
gen_ function by removing * prefix.
(vsx_reduc_<VEC_reduc_name>_v4sf): Likewise.

From-SVN: r227965

gcc/ChangeLog
gcc/config/rs6000/altivec.md
gcc/config/rs6000/vector.md
gcc/config/rs6000/vsx.md

index 970ebae979fd1645dd2ae34b79ca6c96977a53ab..ce9a20f0eb12e5f0694a74a26bba4193541526f6 100644 (file)
@@ -1,3 +1,18 @@
+2015-09-21  Alan Lawrence  <alan.lawrence@arm.com>
+
+       * config/rs6000/altivec.md (reduc_splus_<mode>): Rename to...
+       (reduc_plus_scal_<mode>): ...this, add rs6000_expand_vector_extract.
+       (reduc_uplus_v16qi): Remove.
+
+       * config/rs6000/vector.md (VEC_reduc_name): Change "splus" to "plus".
+       (reduc_<VEC_reduc_name>_v2df): Remove.
+       (reduc_<VEC_reduc_name>_v4sf): Remove.
+       (reduc_<VEC_reduc:VEC_reduc_name>_scal_<VEC_F:name>): New.
+
+       * config/rs6000/vsx.md (vsx_reduc_<VEC_reduc_name>_v2df): Declare
+       gen_ function by removing * prefix.
+       (vsx_reduc_<VEC_reduc_name>_v4sf): Likewise.
+
 2015-09-21  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR middle-end/60832
index 9cacca49050d78f46d41b0913e23b9c1028c8e35..5f6c0f5540e2cd45409bc7e521562e3bc1ffe136 100644 (file)
   operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
 })
 
-(define_expand "reduc_splus_<mode>"
-  [(set (match_operand:VIshort 0 "register_operand" "=v")
+(define_expand "reduc_plus_scal_<mode>"
+  [(set (match_operand:<VI_scalar> 0 "register_operand" "=v")
         (unspec:VIshort [(match_operand:VIshort 1 "register_operand" "v")]
                        UNSPEC_REDUC_PLUS))]
   "TARGET_ALTIVEC"
 {
   rtx vzero = gen_reg_rtx (V4SImode);
   rtx vtmp1 = gen_reg_rtx (V4SImode);
-  rtx dest = gen_lowpart (V4SImode, operands[0]);
+  rtx vtmp2 = gen_reg_rtx (<MODE>mode);
+  rtx dest = gen_lowpart (V4SImode, vtmp2);
+  int elt = BYTES_BIG_ENDIAN ? GET_MODE_NUNITS (<MODE>mode) - 1 : 0;
 
   emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
   emit_insn (gen_altivec_vsum4s<VI_char>s (vtmp1, operands[1], vzero));
   emit_insn (gen_altivec_vsumsws_direct (dest, vtmp1, vzero));
-  DONE;
-})
-
-(define_expand "reduc_uplus_v16qi"
-  [(set (match_operand:V16QI 0 "register_operand" "=v")
-        (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")]
-                     UNSPEC_REDUC_PLUS))]
-  "TARGET_ALTIVEC"
-{
-  rtx vzero = gen_reg_rtx (V4SImode);
-  rtx vtmp1 = gen_reg_rtx (V4SImode);
-  rtx dest = gen_lowpart (V4SImode, operands[0]);
-
-  emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
-  emit_insn (gen_altivec_vsum4ubs (vtmp1, operands[1], vzero));
-  emit_insn (gen_altivec_vsumsws_direct (dest, vtmp1, vzero));
+  rs6000_expand_vector_extract (operands[0], vtmp2, elt);
   DONE;
 })
 
index 8821dec59891c03a7188791d427664653a57a486..d8699c8a0328baed1ee3a99d087a596c1c44fa68 100644 (file)
@@ -78,7 +78,7 @@
 ;; Vector reduction code iterators
 (define_code_iterator VEC_reduc [plus smin smax])
 
-(define_code_attr VEC_reduc_name [(plus "splus")
+(define_code_attr VEC_reduc_name [(plus "plus")
                                  (smin "smin")
                                  (smax "smax")])
 
   "")
 \f
 ;; Vector reduction expanders for VSX
-
-(define_expand "reduc_<VEC_reduc_name>_v2df"
-  [(parallel [(set (match_operand:V2DF 0 "vfloat_operand" "")
-                  (VEC_reduc:V2DF
-                   (vec_concat:V2DF
-                    (vec_select:DF
-                     (match_operand:V2DF 1 "vfloat_operand" "")
-                     (parallel [(const_int 1)]))
-                    (vec_select:DF
-                     (match_dup 1)
-                     (parallel [(const_int 0)])))
-                   (match_dup 1)))
-             (clobber (match_scratch:V2DF 2 ""))])]
-  "VECTOR_UNIT_VSX_P (V2DFmode)"
-  "")
-
-; The (VEC_reduc:V4SF
+; The (VEC_reduc:...
 ;      (op1)
-;      (unspec:V4SF [(const_int 0)] UNSPEC_REDUC))
+;      (unspec:... [(const_int 0)] UNSPEC_REDUC))
 ;
 ; is to allow us to use a code iterator, but not completely list all of the
 ; vector rotates, etc. to prevent canonicalization
 
-(define_expand "reduc_<VEC_reduc_name>_v4sf"
-  [(parallel [(set (match_operand:V4SF 0 "vfloat_operand" "")
-                  (VEC_reduc:V4SF
-                   (unspec:V4SF [(const_int 0)] UNSPEC_REDUC)
-                   (match_operand:V4SF 1 "vfloat_operand" "")))
-             (clobber (match_scratch:V4SF 2 ""))
-             (clobber (match_scratch:V4SF 3 ""))])]
-  "VECTOR_UNIT_VSX_P (V4SFmode)"
-  "")
+
+(define_expand "reduc_<VEC_reduc:VEC_reduc_name>_scal_<VEC_F:mode>"
+  [(match_operand:<VEC_base> 0 "register_operand" "")
+   (VEC_reduc:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
+                   (unspec:VEC_F [(const_int 0)] UNSPEC_REDUC))]
+  "VECTOR_UNIT_VSX_P (<VEC_F:MODE>mode)"
+  {
+    rtx vec = gen_reg_rtx (<VEC_F:MODE>mode);
+    rtx elt = BYTES_BIG_ENDIAN
+               ? gen_int_mode (GET_MODE_NUNITS (<VEC_F:MODE>mode) - 1, QImode)
+               : const0_rtx;
+    emit_insn (gen_vsx_reduc_<VEC_reduc:VEC_reduc_name>_<VEC_F:mode> (vec,
+       operand1));
+    emit_insn (gen_vsx_extract_<VEC_F:mode> (operand0, vec, elt));
+    DONE;
+  })
 
 \f
 ;;; Expanders for vector insn patterns shared between the SPE and TARGET_PAIRED systems.
index 7f366b8d69a033e9276d146190a42aa668f56b35..0e110ae2f7f27a7a4deff4ec83603773b68398bc 100644 (file)
 \f
 ;; Vector reduction insns and splitters
 
-(define_insn_and_split "*vsx_reduc_<VEC_reduc_name>_v2df"
+(define_insn_and_split "vsx_reduc_<VEC_reduc_name>_v2df"
   [(set (match_operand:V2DF 0 "vfloat_operand" "=&wd,&?wa,wd,?wa")
        (VEC_reduc:V2DF
         (vec_concat:V2DF
   [(set_attr "length" "8")
    (set_attr "type" "veccomplex")])
 
-(define_insn_and_split "*vsx_reduc_<VEC_reduc_name>_v4sf"
+(define_insn_and_split "vsx_reduc_<VEC_reduc_name>_v4sf"
   [(set (match_operand:V4SF 0 "vfloat_operand" "=wf,?wa")
        (VEC_reduc:V4SF
         (unspec:V4SF [(const_int 0)] UNSPEC_REDUC)