Hi, [PATCH, rs6000] (v2) Gimple folding for vec_madd() Add support for gimple folding of the vec_madd() (vector multiply-add) intrinsics. Per earlier feedback and education, this now includes the addition of a "define_expand fmav8hi4" in altivec.md. Testcase coverage is provided by the existing tests as gcc.target/powerpc/fold-vec-madd-*.c Sniff-tests passed. Regtests will be kicked off shortly. OK for trunk? (pending successful test results, of course:-) ) Thanks, -Will [gcc] 2017-10-26 Will Schmidt <will_schm...@vnet.ibm.com> * config/rs6000/rs6000.c: (rs6000_gimple_fold_builtin) Add support for gimple folding of vec_madd() intrinsics. * config/rs6000/altivec.md: Add define_expand fmav8hi4
diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index 6ea529b..36e6ddd 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -943,10 +943,22 @@ (match_operand:V8HI 3 "register_operand" "v")))] "TARGET_ALTIVEC" "vmladduhm %0,%1,%2,%3" [(set_attr "type" "veccomplex")]) +(define_expand "fmav8hi4" + [(use (match_operand:V8HI 0 "register_operand" "")) + (use (match_operand:V8HI 1 "register_operand" "")) + (use (match_operand:V8HI 2 "register_operand" "")) + (use (match_operand:V8HI 3 "register_operand" ""))] + "TARGET_ALTIVEC" +{ + emit_insn (gen_altivec_vmladduhm (operands[0], operands[1], + operands[2], operands[3])); + DONE; +}) + (define_expand "altivec_vmrghb" [(use (match_operand:V16QI 0 "register_operand" "")) (use (match_operand:V16QI 1 "register_operand" "")) (use (match_operand:V16QI 2 "register_operand" ""))] "TARGET_ALTIVEC" diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 4837e14..1cd4278 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -16606,10 +16606,25 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) build_int_cst (arg2_type, 0)), arg0); gimple_set_location (g, loc); gsi_replace (gsi, g, true); return true; } + /* vec_madd (Float) */ + case ALTIVEC_BUILTIN_VMADDFP: + case VSX_BUILTIN_XVMADDDP: + case ALTIVEC_BUILTIN_VMLADDUHM: + { + arg0 = gimple_call_arg (stmt, 0); + arg1 = gimple_call_arg (stmt, 1); + tree arg2 = gimple_call_arg (stmt, 2); + lhs = gimple_call_lhs (stmt); + gimple *g = gimple_build_assign (lhs, FMA_EXPR , arg0, arg1, arg2); + gimple_set_location (g, gimple_location (stmt)); + gsi_replace (gsi, g, true); + return true; + } + default: if (TARGET_DEBUG_BUILTIN) fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s\n", fn_code, fn_name1, fn_name2); break;