This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, rs6000] (v2) Gimple folding for vec_madd()
- From: Will Schmidt <will_schmidt at vnet dot ibm dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Segher Boessenkool <segher at kernel dot crashing dot org>, Bill Schmidt <wschmidt at linux dot vnet dot ibm dot com>, David Edelsohn <dje dot gcc at gmail dot com>
- Date: Thu, 26 Oct 2017 17:13:38 -0500
- Subject: Re: [PATCH, rs6000] (v2) Gimple folding for vec_madd()
- Authentication-results: sourceware.org; auth=none
- References: <1508942330.26707.184.camel@brimstone.rchland.ibm.com> <CAFiYyc2+LO2PTPkYZkKMVO5geM=nqGvXfeoaZZ_WiiE7u7UByA@mail.gmail.com> <1509028202.26707.214.camel@brimstone.rchland.ibm.com> <CAFiYyc3Zf2K_fQufWDiekC_osCuk4CDVx65mqZEG+tmWU8QU=w@mail.gmail.com> <CAFiYyc0r1HGCUjO6ZWxmV2Ei8LN92j5WtO8tXGr+F4HRu2Sp8A@mail.gmail.com>
- Reply-to: will_schmidt at vnet dot ibm dot com
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_schmidt@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;