diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index d46ef191409211a0a9d213b57fb4e657cd5a3cb4..b79f7aa477ec700743ae7c5734672571e395b79d 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -2596,35 +2596,22 @@ operands[3] = gen_reg_rtx (GET_MODE (operands[0])); }) -(define_expand "reduc_splus_" - [(set (match_operand:VIshort 0 "register_operand" "=v") +(define_expand "reduc_plus_scal_" + [(set (match_operand: 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); + rtx dest = gen_lowpart (V4SImode, vtmp2); + HOST_WIDE_INT last_elem = GET_MODE_NUNITS (mode) - 1; emit_insn (gen_altivec_vspltisw (vzero, const0_rtx)); emit_insn (gen_altivec_vsum4ss (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, last_elem); DONE; }) diff --git a/gcc/config/rs6000/vector.md b/gcc/config/rs6000/vector.md index e2946bd6e312e909471253fc2d75a4b25e050f82..cc01a96cb681a61b0708b34ffa4339529f3c1b9e 100644 --- a/gcc/config/rs6000/vector.md +++ b/gcc/config/rs6000/vector.md @@ -77,7 +77,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")]) @@ -990,20 +990,16 @@ ;; Vector reduction expanders for VSX -(define_expand "reduc__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 ""))])] +(define_expand "reduc__scal_v2df" + [(match_operand:DF 0 "register_operand" "") + (VEC_reduc:V2DF (match_operand:V2DF 1 "vfloat_operand" "") (const_int 0))] "VECTOR_UNIT_VSX_P (V2DFmode)" - "") + { + rtx vec = gen_reg_rtx (V2DFmode); + emit_insn (gen_vsx_reduc__v2df (vec, operand1)); + emit_insn (gen_vsx_extract_v2df (operand0, vec, const1_rtx)); + DONE; + }) ; The (VEC_reduc:V4SF ; (op1) @@ -1012,13 +1008,16 @@ ; 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__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" ""))) +(define_expand "reduc__scal_v4sf" + [(parallel [(set (match_operand:SF 0 "vfloat_operand" "") + (vec_select:SF + (VEC_reduc:V4SF + (unspec:V4SF [(const_int 0)] UNSPEC_REDUC) + (match_operand:V4SF 1 "vfloat_operand" "")) + (parallel [(const_int 3)]))) (clobber (match_scratch:V4SF 2 "")) - (clobber (match_scratch:V4SF 3 ""))])] + (clobber (match_scratch:V4SF 3 "")) + (clobber (match_scratch:V4SF 4 ""))])] "VECTOR_UNIT_VSX_P (V4SFmode)" "") diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 27d464e07f7b77166047dd9ba41966aef411c029..2a30039c2bf415ab92fbd0b806787a74b15d7dcb 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -2150,7 +2150,7 @@ ;; Vector reduction insns and splitters -(define_insn_and_split "*vsx_reduc__v2df" +(define_insn_and_split "vsx_reduc__v2df" [(set (match_operand:V2DF 0 "vfloat_operand" "=&wd,&?wa,wd,?wa") (VEC_reduc:V2DF (vec_concat:V2DF