From patchwork Mon Jul 2 03:41:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 937659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-480817-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=twiddle.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vUuGFGHl"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41JtNf6MJPz9s29 for ; Mon, 2 Jul 2018 13:42:10 +1000 (AEST) Received: (qmail 117192 invoked by alias); 2 Jul 2018 03:41:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 117075 invoked by uid 89); 2 Jul 2018 03:41:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:sk:a187-v6, HX-Received:66c4, implements, whereas X-HELO: mail-pf0-f196.google.com Received: from mail-pf0-f196.google.com (HELO mail-pf0-f196.google.com) (209.85.192.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Jul 2018 03:41:40 +0000 Received: by mail-pf0-f196.google.com with SMTP id a11-v6so6816449pff.8 for ; Sun, 01 Jul 2018 20:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=M0mRNnnTL0MifHyZdmO01YcLaj2nhxk3IEQRRpSY2D0=; b=vUuGFGHlJhFVe2PqSHdet4v7nyFY7OW20ekwEdAhvF72Ht47/FL/eguBaWBKCiRdCT QC1PYJlrX8E4WIJhbAoXaJdeev0YRAEK20KMmOnnrKozCWdKxAcSSEtaANLTvgM/bkbw alB1SeU2Ts05CUngKNSsjMjJa4+tuQ3aLeaQtVh4LNPJROr7RanyhcAM7MudHOt6lPBr 1hMwNRxy6tYWyrJDORkAV7Bn4qHKXgs/7eLgPsZBc98nhA4lnmDLg/ZbieyzqVUhljpZ 66WsSmZfqVgFGFddBg3oNSMPqxa5vKvj7sMRb4JP5hsf9IRzCUCpOS35cUYeomrJB+5W atrg== Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id 141-v6sm5014649pfu.167.2018.07.01.20.41.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 01 Jul 2018 20:41:37 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, marcus.shawcroft@arm.com, james.greenhalgh@arm.com Subject: [PATCH, aarch64 3/4] aarch64: Add movprfx alternatives for predicate patterns Date: Sun, 1 Jul 2018 20:41:32 -0700 Message-Id: <20180702034133.12511-4-rth@twiddle.net> In-Reply-To: <20180702034133.12511-1-rth@twiddle.net> References: <20180702034133.12511-1-rth@twiddle.net> X-IsSubscribed: yes * config/aarch64/iterators.md (SVE_INT_BINARY_REV): Remove. (SVE_COND_FP_BINARY_REV): Remove. (sve_int_op_rev, sve_fp_op_rev): New. * config/aarch64/aarch64-sve.md (*cond__0): New. (*cond__0): New. (*cond__0): New. (*cond__2): Rename, add movprfx alternative. (*cond__2): Similarly. (*cond__2): Similarly. (*cond__3): Similarly; use sve_int_op_rev. (*cond__3): Similarly. (*cond__3): Similarly; use sve_fp_op_rev. --- gcc/config/aarch64/aarch64.c | 8 +- gcc/config/aarch64/aarch64-sve.md | 163 ++++++++++++++++++++++-------- gcc/config/aarch64/iterators.md | 26 ++++- 3 files changed, 149 insertions(+), 48 deletions(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b88e7cac27a..3af7e98e166 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -16098,7 +16098,13 @@ aarch64_sve_prepare_conditional_op (rtx *operands, unsigned int nops, whereas selecting the input avoids the MOVPRFX: SEL Z0.S, P1, Z2.S, Z4.S - ADD Z0.S, P1/M, Z0.S, Z3.S. */ + ADD Z0.S, P1/M, Z0.S, Z3.S. + + ??? Matching the other input can produce + + MOVPRFX Z4.S, P1/M, Z2.S + ADD Z4.S, P1/M, Z4.S, Z3.S + */ machine_mode mode = GET_MODE (operands[0]); rtx temp = gen_reg_rtx (mode); rtvec vec = gen_rtvec (3, operands[1], operands[2], operands[nops - 1]); diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md index 2aceef65c80..db16affc093 100644 --- a/gcc/config/aarch64/aarch64-sve.md +++ b/gcc/config/aarch64/aarch64-sve.md @@ -1841,57 +1841,108 @@ }) ;; Predicated integer operations. -(define_insn "*cond_" - [(set (match_operand:SVE_I 0 "register_operand" "=w") +;; All other things being equal, prefer the patterns for which the +;; destination matches the select input, as that gives us the most +;; freedom to swap the other operands. + +(define_insn "*cond__0" + [(set (match_operand:SVE_I 0 "register_operand" "+w, w, ?&w") (unspec:SVE_I - [(match_operand: 1 "register_operand" "Upl") + [(match_operand: 1 "register_operand" "Upl, Upl, Upl") (SVE_INT_BINARY:SVE_I - (match_operand:SVE_I 2 "register_operand" "0") - (match_operand:SVE_I 3 "register_operand" "w")) - (match_dup 2)] + (match_operand:SVE_I 2 "register_operand" "0, w, w") + (match_operand:SVE_I 3 "register_operand" "w, 0, w")) + (match_dup 0)] UNSPEC_SEL))] "TARGET_SVE" - "\t%0., %1/m, %0., %3." + "@ + \t%0., %1/m, %0., %3. + \t%0., %1/m, %0., %2. + movprfx\t%0, %1/m, %2\;\t%0., %1/m, %0., %3." + [(set_attr "movprfx" "*,*,yes")] ) -(define_insn "*cond_" - [(set (match_operand:SVE_SDI 0 "register_operand" "=w") +(define_insn "*cond__0" + [(set (match_operand:SVE_SDI 0 "register_operand" "+w, w, ?&w") (unspec:SVE_SDI - [(match_operand: 1 "register_operand" "Upl") + [(match_operand: 1 "register_operand" "Upl, Upl, Upl") (SVE_INT_BINARY_SD:SVE_SDI - (match_operand:SVE_SDI 2 "register_operand" "0") - (match_operand:SVE_SDI 3 "register_operand" "w")) - (match_dup 2)] + (match_operand:SVE_SDI 2 "register_operand" "0, w, w") + (match_operand:SVE_SDI 3 "register_operand" "w, 0, w")) + (match_dup 0)] UNSPEC_SEL))] "TARGET_SVE" - "\t%0., %1/m, %0., %3." + "@ + \t%0., %1/m, %0., %3. + \t%0., %1/m, %0., %2. + movprfx\t%0, %1/m, %2\;\t%0., %1/m, %0., %3." + [(set_attr "movprfx" "*,*,yes")] ) -;; Predicated integer operations with the operands reversed. -(define_insn "*cond_" - [(set (match_operand:SVE_I 0 "register_operand" "=w") +;; Predicated integer operations with select matching the first operand. +(define_insn "*cond__2" + [(set (match_operand:SVE_I 0 "register_operand" "=w, ?&w") (unspec:SVE_I - [(match_operand: 1 "register_operand" "Upl") - (SVE_INT_BINARY_REV:SVE_I - (match_operand:SVE_I 2 "register_operand" "w") - (match_operand:SVE_I 3 "register_operand" "0")) - (match_dup 3)] + [(match_operand: 1 "register_operand" "Upl, Upl") + (SVE_INT_BINARY:SVE_I + (match_operand:SVE_I 2 "register_operand" "0, w") + (match_operand:SVE_I 3 "register_operand" "w, w")) + (match_dup 2)] UNSPEC_SEL))] "TARGET_SVE" - "r\t%0., %1/m, %0., %2." + "@ + \t%0., %1/m, %0., %3. + movprfx\t%0, %2\;\t%0., %1/m, %0., %3." + [(set_attr "movprfx" "*,yes")] ) -(define_insn "*cond_" - [(set (match_operand:SVE_SDI 0 "register_operand" "=w") +(define_insn "*cond__2" + [(set (match_operand:SVE_SDI 0 "register_operand" "=w, ?&w") (unspec:SVE_SDI - [(match_operand: 1 "register_operand" "Upl") + [(match_operand: 1 "register_operand" "Upl, Upl") (SVE_INT_BINARY_SD:SVE_SDI - (match_operand:SVE_SDI 2 "register_operand" "w") - (match_operand:SVE_SDI 3 "register_operand" "0")) + (match_operand:SVE_SDI 2 "register_operand" "0, w") + (match_operand:SVE_SDI 3 "register_operand" "w, w")) + (match_dup 2)] + UNSPEC_SEL))] + "TARGET_SVE" + "@ + \t%0., %1/m, %0., %3. + movprfx\t%0, %2\;\t%0., %1/m, %0., %3." + [(set_attr "movprfx" "*,yes")] +) + +;; Predicated integer operations with select matching the second operand. +(define_insn "*cond__3" + [(set (match_operand:SVE_I 0 "register_operand" "=w, ?&w") + (unspec:SVE_I + [(match_operand: 1 "register_operand" "Upl, Upl") + (SVE_INT_BINARY:SVE_I + (match_operand:SVE_I 2 "register_operand" "w, w") + (match_operand:SVE_I 3 "register_operand" "0, w")) (match_dup 3)] UNSPEC_SEL))] "TARGET_SVE" - "r\t%0., %1/m, %0., %2." + "@ + \t%0., %1/m, %0., %2. + movprfx\t%0, %3\;\t%0., %1/m, %0., %2." + [(set_attr "movprfx" "*,yes")] +) + +(define_insn "*cond__3" + [(set (match_operand:SVE_SDI 0 "register_operand" "=w, ?&w") + (unspec:SVE_SDI + [(match_operand: 1 "register_operand" "Upl, Upl") + (SVE_INT_BINARY_SD:SVE_SDI + (match_operand:SVE_SDI 2 "register_operand" "w, w") + (match_operand:SVE_SDI 3 "register_operand" "0, w")) + (match_dup 3)] + UNSPEC_SEL))] + "TARGET_SVE" + "@ + \t%0., %1/m, %0., %2. + movprfx\t%0, %3\;\t%0., %1/m, %0., %2." + [(set_attr "movprfx" "*,yes")] ) ;; Set operand 0 to the last active element in operand 3, or to tied @@ -2687,34 +2738,60 @@ aarch64_sve_prepare_conditional_op (operands, 5, ); }) -;; Predicated floating-point operations. -(define_insn "*cond_" - [(set (match_operand:SVE_F 0 "register_operand" "=w") +;; Predicated floating-point operations with select matching output. +(define_insn "*cond__0" + [(set (match_operand:SVE_F 0 "register_operand" "+w, w, ?&w") (unspec:SVE_F - [(match_operand: 1 "register_operand" "Upl") + [(match_operand: 1 "register_operand" "Upl, Upl, Upl") (unspec:SVE_F - [(match_operand:SVE_F 2 "register_operand" "0") - (match_operand:SVE_F 3 "register_operand" "w")] + [(match_dup 1) + (match_operand:SVE_F 2 "register_operand" "0, w, w") + (match_operand:SVE_F 3 "register_operand" "w, 0, w")] + SVE_COND_FP_BINARY) + (match_dup 0)] + UNSPEC_SEL))] + "TARGET_SVE" + "@ + \t%0., %1/m, %0., %3. + \t%0., %1/m, %0., %2. + movprfx\t%0, %1/m, %2\;\t%0., %1/m, %0., %3." + [(set_attr "movprfx" "*,*,yes")] +) + +;; Predicated floating-point operations with select matching first operand. +(define_insn "*cond__2" + [(set (match_operand:SVE_F 0 "register_operand" "=w, ?&w") + (unspec:SVE_F + [(match_operand: 1 "register_operand" "Upl, Upl") + (unspec:SVE_F + [(match_operand:SVE_F 2 "register_operand" "0, w") + (match_operand:SVE_F 3 "register_operand" "w, w")] SVE_COND_FP_BINARY) (match_dup 2)] UNSPEC_SEL))] "TARGET_SVE" - "\t%0., %1/m, %0., %3." + "@ + \t%0., %1/m, %0., %3. + movprfx\t%0, %2\;\t%0., %1/m, %0., %3." + [(set_attr "movprfx" "*,yes")] ) -;; Predicated floating-point operations with the operands reversed. -(define_insn "*cond_" - [(set (match_operand:SVE_F 0 "register_operand" "=w") +;; Predicated floating-point operations with select matching second operand. +(define_insn "*cond__3" + [(set (match_operand:SVE_F 0 "register_operand" "=w, ?&w") (unspec:SVE_F - [(match_operand: 1 "register_operand" "Upl") + [(match_operand: 1 "register_operand" "Upl, Upl") (unspec:SVE_F - [(match_operand:SVE_F 2 "register_operand" "w") - (match_operand:SVE_F 3 "register_operand" "0")] + [(match_operand:SVE_F 2 "register_operand" "w, w") + (match_operand:SVE_F 3 "register_operand" "0, w")] SVE_COND_FP_BINARY) (match_dup 3)] UNSPEC_SEL))] "TARGET_SVE" - "r\t%0., %1/m, %0., %2." + "@ + \t%0., %1/m, %0., %2. + movprfx\t%0, %3\;\t%0., %1/m, %0., %2." + [(set_attr "movprfx" "*,yes")] ) ;; Shift an SVE vector left and insert a scalar into element 0. diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index c5ef2eecf20..965dc6bf4f3 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -1207,11 +1207,11 @@ ;; SVE floating-point unary operations. (define_code_iterator SVE_FP_UNARY [neg abs sqrt]) +;; SVE integer binary operations. (define_code_iterator SVE_INT_BINARY [plus minus mult smax umax smin umin and ior xor]) -(define_code_iterator SVE_INT_BINARY_REV [minus]) - +;; SVE integer binary division operations. (define_code_iterator SVE_INT_BINARY_SD [div udiv]) ;; SVE integer comparisons. @@ -1402,6 +1402,19 @@ (not "not") (popcount "cnt")]) +(define_code_attr sve_int_op_rev [(plus "add") + (minus "subr") + (mult "mul") + (div "sdivr") + (udiv "udivr") + (smin "smin") + (smax "smax") + (umin "umin") + (umax "umax") + (and "and") + (ior "orr") + (xor "eor")]) + ;; The floating-point SVE instruction that implements an rtx code. (define_code_attr sve_fp_op [(plus "fadd") (neg "fneg") @@ -1550,8 +1563,6 @@ UNSPEC_COND_MUL UNSPEC_COND_DIV UNSPEC_COND_MAX UNSPEC_COND_MIN]) -(define_int_iterator SVE_COND_FP_BINARY_REV [UNSPEC_COND_SUB UNSPEC_COND_DIV]) - (define_int_iterator SVE_COND_FP_CMP [UNSPEC_COND_LT UNSPEC_COND_LE UNSPEC_COND_EQ UNSPEC_COND_NE UNSPEC_COND_GE UNSPEC_COND_GT]) @@ -1802,6 +1813,13 @@ (UNSPEC_COND_MAX "fmaxnm") (UNSPEC_COND_MIN "fminnm")]) +(define_int_attr sve_fp_op_rev [(UNSPEC_COND_ADD "fadd") + (UNSPEC_COND_SUB "fsubr") + (UNSPEC_COND_MUL "fmul") + (UNSPEC_COND_DIV "fdivr") + (UNSPEC_COND_MAX "fmaxnm") + (UNSPEC_COND_MIN "fminnm")]) + (define_int_attr commutative [(UNSPEC_COND_ADD "true") (UNSPEC_COND_SUB "false") (UNSPEC_COND_MUL "true")