From patchwork Wed Aug 7 19:10:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1143630 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-506454-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="j1eInuhn"; 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 463h0V2vpjz9sN6 for ; Thu, 8 Aug 2019 05:10:17 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=YwTD6z4A92uSomRp6Z9hGnUKO+0PM7ySuTmyy9j4IpMS+/LDnUILV bjHPr+ZGcdL+MkG6308TxXaWJpK0WMoSwPYlNQ3FC1qq/Vpb1mk8fdZzdRtOd11d nSFtvX9flhHuBJIUk7NN1rIBxRam2Z8y4IE9M7aFWrQnmhHSB+e3kw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=2kIy9VXlxrC2IHKaSfqbgMdO6As=; b=j1eInuhnCXe4QHpO5vBH nFXU1SZpycOASFlbEpxXt29yqypGcC/xxZflEtozvDkEqYDtI56kdLq3X0J2DyJ4 NQbCVmhDIkfk41uNq0xUGDes88OMVSbRvMXD1gNhNYiYGNSNFk96Q6q94GEOZlON X3QQ9fvckBEsdySAQPIqCEk= Received: (qmail 112257 invoked by alias); 7 Aug 2019 19:10:10 -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 112205 invoked by uid 89); 7 Aug 2019 19:10:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:2775, r274191 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Aug 2019 19:10:09 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7D6C228 for ; Wed, 7 Aug 2019 12:10:07 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 23EE13F575 for ; Wed, 7 Aug 2019 12:10:07 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed][AArch64] Prefer FPRs over GPRs for CLASTB Date: Wed, 07 Aug 2019 20:10:05 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes This patch makes the SVE CLASTB GPR alternative more expensive than the FPR alternative in order to avoid unnecessary cross-file moves. It also fixes the prefix used to print the FPR; only handles 32-bit and 64-bit elements. Tested on aarch64-linux-gnu (with and without SVE) and aarch64_be-elf. Applied as r274191. Richard 2019-08-07 Richard Sandiford gcc/ * config/aarch64/aarch64-sve.md (fold_extract_last_): Disparage the GPR alternative relative to the FPR one. Fix handling of 8-bit and 16-bit FPR values. gcc/testsuite/ * gcc.target/aarch64/sve/clastb_8.c: New test. Index: gcc/config/aarch64/aarch64-sve.md =================================================================== --- gcc/config/aarch64/aarch64-sve.md 2019-08-07 20:05:39.025879238 +0100 +++ gcc/config/aarch64/aarch64-sve.md 2019-08-07 20:07:56.256858738 +0100 @@ -3104,7 +3104,7 @@ (define_insn "ptest_ptrue" ;; Set operand 0 to the last active element in operand 3, or to tied ;; operand 1 if no elements are active. (define_insn "fold_extract_last_" - [(set (match_operand: 0 "register_operand" "=r, w") + [(set (match_operand: 0 "register_operand" "=?r, w") (unspec: [(match_operand: 1 "register_operand" "0, 0") (match_operand: 2 "register_operand" "Upl, Upl") @@ -3113,7 +3113,7 @@ (define_insn "fold_extract_last_" "TARGET_SVE" "@ clastb\t%0, %2, %0, %3. - clastb\t%0, %2, %0, %3." + clastb\t%0, %2, %0, %3." ) ;; ------------------------------------------------------------------------- Index: gcc/testsuite/gcc.target/aarch64/sve/clastb_8.c =================================================================== --- /dev/null 2019-07-30 08:53:31.317691683 +0100 +++ gcc/testsuite/gcc.target/aarch64/sve/clastb_8.c 2019-08-07 20:07:56.256858738 +0100 @@ -0,0 +1,25 @@ +/* { dg-do assemble { target aarch64_asm_sve_ok } } */ +/* { dg-options "-O2 -ftree-vectorize -msve-vector-bits=256 --save-temps" } */ + +#include + +#define TEST_TYPE(TYPE) \ + void \ + test_##TYPE (TYPE *ptr, TYPE *a, TYPE *b, TYPE min_v) \ + { \ + TYPE last = *ptr; \ + for (int i = 0; i < 1024; i++) \ + if (a[i] < min_v) \ + last = b[i]; \ + *ptr = last; \ + } + +TEST_TYPE (uint8_t); +TEST_TYPE (uint16_t); +TEST_TYPE (uint32_t); +TEST_TYPE (uint64_t); + +/* { dg-final { scan-assembler {\tclastb\t(b[0-9]+), p[0-7], \1, z[0-9]+\.b\n} } } */ +/* { dg-final { scan-assembler {\tclastb\t(h[0-9]+), p[0-7], \1, z[0-9]+\.h\n} } } */ +/* { dg-final { scan-assembler {\tclastb\t(s[0-9]+), p[0-7], \1, z[0-9]+\.s\n} } } */ +/* { dg-final { scan-assembler {\tclastb\t(d[0-9]+), p[0-7], \1, z[0-9]+\.d\n} } } */