From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65489 invoked by alias); 27 Oct 2017 15:51:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 65480 invoked by uid 89); 27 Oct 2017 15:51:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Oct 2017 15:51:12 +0000 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9RFlZdQ134307 for ; Fri, 27 Oct 2017 11:51:08 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dv44gmxkk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 27 Oct 2017 11:51:07 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Oct 2017 11:51:07 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 27 Oct 2017 11:51:05 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9RFp5ta46792922; Fri, 27 Oct 2017 15:51:05 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D585AC03A; Fri, 27 Oct 2017 11:51:50 -0400 (EDT) Received: from [9.10.86.107] (unknown [9.10.86.107]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id E90D8AC041; Fri, 27 Oct 2017 11:51:49 -0400 (EDT) Subject: Re: [PATCH, rs6000] (v3) Gimple folding for vec_madd() From: Will Schmidt Reply-To: will_schmidt@vnet.ibm.com To: Segher Boessenkool Cc: Richard Biener , GCC Patches , Bill Schmidt , David Edelsohn In-Reply-To: <20171026234133.GP4406@gate.crashing.org> References: <1508942330.26707.184.camel@brimstone.rchland.ibm.com> <1509028202.26707.214.camel@brimstone.rchland.ibm.com> <1509056018.26707.226.camel@brimstone.rchland.ibm.com> <20171026234133.GP4406@gate.crashing.org> Content-Type: text/plain; charset="UTF-8" Date: Fri, 27 Oct 2017 15:56:00 -0000 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17102715-0040-0000-0000-000003B970A1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007962; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00937268; UDB=6.00472385; IPR=6.00717531; BA=6.00005660; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017745; XFM=3.00000015; UTC=2017-10-27 15:51:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102715-0041-0000-0000-000007AE7F2F Message-Id: <1509119464.26707.231.camel@brimstone.rchland.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-27_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710270208 X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg02088.txt.bz2 Hi, V3. :-) [PATCH, rs6000] (v2) Gimple folding for vec_madd() Add support for gimple folding of the vec_madd() (vector multiply-add) intrinsics. Renamed the define_insn of altivec_vmladduhm to fmav8hi4, Refreshed the caller of gen_altivec_vmladduhm to call gen_fmav8hi, and updated the rs6000-builtin.def entry for VMLADDUHM to point to the new name. With this refresh I am no longer adding a define_expand. Plus a few cosmetic tweaks per feedback. 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? Thanks, -Will [gcc] 2017-10-27 Will Schmidt * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for gimple folding of vec_madd() intrinsics. * config/rs6000/altivec.md: Rename altivec_vmladduhm to fmav8hi4 * config/rs6000/rs6000-builtin.def: Rename vmladduhm to fmav8hi4 diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index 6ea529b..b2f173d 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -793,15 +793,16 @@ "TARGET_ALTIVEC" { rtx zero = gen_reg_rtx (V8HImode); emit_insn (gen_altivec_vspltish (zero, const0_rtx)); - emit_insn (gen_altivec_vmladduhm(operands[0], operands[1], operands[2], zero)); + emit_insn (gen_fmav8hi4 (operands[0], operands[1], operands[2], zero)); DONE; }) + ;; Fused multiply subtract (define_insn "*altivec_vnmsubfp" [(set (match_operand:V4SF 0 "register_operand" "=v") (neg:V4SF (fma:V4SF (match_operand:V4SF 1 "register_operand" "v") @@ -934,11 +935,11 @@ (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vmhraddshs %0,%1,%2,%3" [(set_attr "type" "veccomplex")]) -(define_insn "altivec_vmladduhm" +(define_insn "fmav8hi4" [(set (match_operand:V8HI 0 "register_operand" "=v") (plus:V8HI (mult:V8HI (match_operand:V8HI 1 "register_operand" "v") (match_operand:V8HI 2 "register_operand" "v")) (match_operand:V8HI 3 "register_operand" "v")))] "TARGET_ALTIVEC" diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index ac9ddae..7834bef 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -959,11 +959,11 @@ BU_SPECIAL_X (RS6000_BUILTIN_NONE, NULL, 0, RS6000_BTC_MISC) /* 3 argument Altivec builtins. */ BU_ALTIVEC_3 (VMADDFP, "vmaddfp", FP, fmav4sf4) BU_ALTIVEC_3 (VMHADDSHS, "vmhaddshs", SAT, altivec_vmhaddshs) BU_ALTIVEC_3 (VMHRADDSHS, "vmhraddshs", SAT, altivec_vmhraddshs) -BU_ALTIVEC_3 (VMLADDUHM, "vmladduhm", CONST, altivec_vmladduhm) +BU_ALTIVEC_3 (VMLADDUHM, "vmladduhm", CONST, fmav8hi4) BU_ALTIVEC_3 (VMSUMUBM, "vmsumubm", CONST, altivec_vmsumubm) BU_ALTIVEC_3 (VMSUMMBM, "vmsummbm", CONST, altivec_vmsummbm) BU_ALTIVEC_3 (VMSUMUHM, "vmsumuhm", CONST, altivec_vmsumuhm) BU_ALTIVEC_3 (VMSUMSHM, "vmsumshm", CONST, altivec_vmsumshm) BU_ALTIVEC_3 (VMSUMUHS, "vmsumuhs", SAT, altivec_vmsumuhs) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 4837e14..aef34b7 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -16606,10 +16606,26 @@ 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; } + + /* Vector Fused multiply-add (fma). */ + 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;