From patchwork Thu Jan 4 17:38:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 123447 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp160268qgn; Thu, 4 Jan 2018 09:38:17 -0800 (PST) X-Google-Smtp-Source: ACJfBotb1uoGjcB/qIDaIjbV3zePcXbtyCEUNWehEppOuE/0U2QPIJ7oUnbNK6nAt78Jg5udkiUB X-Received: by 10.159.246.8 with SMTP id b8mr282481pls.93.1515087497879; Thu, 04 Jan 2018 09:38:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515087497; cv=none; d=google.com; s=arc-20160816; b=a1FyYzHNz0nG/HIXVkSnTnPLfeBYX31nzG6tQr7FJ6ZDif+Xt7SF1rT/vavsA0qDpc Icc5ZcubLa8sGnjc1dC+Y032PrN+3TwCZBqO8zFFzf4a2H4kRs4T6NZXLysQa8lwo9D4 kS0I3kV2CisrI0Y+DM2/S/Zjwf6r0RuBqeFSM5/pY6F2MWRiRuZB+HMerRf1geMIBQD8 ZS8FMROz+v+OqF3dL5k+N62LIbcXc2VqLQ5SJXUp0lh12QOyQVJThe2kJYxr4V4wrthr i1BP2a1KXM/ioQ9KI/zPCgqL4OJf7I37Y6XZEwf3fpHXKVQtoGIIgr5zH4LHtAFFVHYA +vtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=UY2BlKJQ9gtQ9aIVJ9Sa7h6jgQbQgYN5nZovufViwfQ=; b=g9Nmt5hXbfXLhTslWaIUpE79mAehfFjGDzaKoun2+fAHMxFpm8B2nQ83kN0iwVWQQi L2+hOm1rx6xDkYuDxEt6iSoeiOF0kkOK0bSJ9J4RnRbF/xERHfbgYgZaTAiZgb5Re9Mz Kw9N5oPD59Q1X7pjUO4hhj3fETchTelEqMBOsUth436E310/xe9jXXM7mQQjFk0BhfGe VN9IfrurlE52GjFe0lRNXGaoglDkJ6XOrSpzdZ1apNZpc5NfOTmNlx1oFvRJ7x9D/Zqp r0q+49m9+iQYhROvZURocjUpaFQV4X1b1NLv86s4zQUlvVPlpdky2cJMi41CNb7da2D7 uTiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FD6G6XIk; spf=pass (google.com: domain of gcc-patches-return-470156-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470156-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id a64si2628710pfl.299.2018.01.04.09.38.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 09:38:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-470156-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FD6G6XIk; spf=pass (google.com: domain of gcc-patches-return-470156-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470156-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=q5hJMkD8NsobUT1PH2Gg8ntfus8OGofxSuptWn83PjfAux6SJSUVm 5KpACPbpL/BtVpXSKze/Cbrg0K6JSSPciJe2zy+e77II5sknZT1ep4PmUWvDVNBr fn7iMZyquCqHZtZC8nlIjn52YetjQJ7sH450QKEhubqvChI6HrwB84= 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=uV59qRN3Sfbqj9owJQsflK41nDs=; b=FD6G6XIk5fLt2yeEAT56 w1vZXQCzNDu0Moy3ewhfcuMkFcesxlHmX74yj64ynmgojslciRg9Ln7RH74jRB6t 33Io3qFtwbImE9wl/OzUUpPdsz3sPgu2e0YMUaJFRkjGhYYxdprRbVgSGaHJzUG1 6GnjfFlw8qrMjbFA5DJWumw= Received: (qmail 10389 invoked by alias); 4 Jan 2018 17:38:06 -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 10356 invoked by uid 89); 4 Jan 2018 17:38:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Works, constant-sized, constantsized, CEIL X-HELO: mail-wm0-f47.google.com Received: from mail-wm0-f47.google.com (HELO mail-wm0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 04 Jan 2018 17:38:04 +0000 Received: by mail-wm0-f47.google.com with SMTP id 9so4842410wme.4 for ; Thu, 04 Jan 2018 09:38:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=UY2BlKJQ9gtQ9aIVJ9Sa7h6jgQbQgYN5nZovufViwfQ=; b=QUH/Fs5ynlZyAg5HO//0XlMfkXE3G/q/D/XU2vRVm1N2588SR79Vdnau8MRfiLjHdl fKefziTcMR6HkHOpBWhM3PKhW0eiq6JCqNsezcdCOp5BN3UJnb1kzY6BydaQBFmi1O2e s0KHNLW18teamRKn/HmJlgGQPv4FnB91D78jH5RZFz5dNRyi3fphs+xrWG9BVnQFDmgc rAude70FSvZBpltXV8hTeagbiyTrTUUiEiWM0Je2GMbo1K9sicRkC1Vv3PA96GG6iDGw nvOGD7cudTV4AGiAvUd6O7afOfEaYmt0Tzca+Nz14EJFVlxxtEHRnnTuZLRB9jh86sRz V5kA== X-Gm-Message-State: AKGB3mLwfDQba4tux1PCcfyMqJYEk7rlf2EdZ8aO/7kuuaTdmWlgzELh bUpq1P5ed21IwhG7x1M6BWcJ+1tY5eY= X-Received: by 10.28.101.132 with SMTP id z126mr183609wmb.106.1515087481896; Thu, 04 Jan 2018 09:38:01 -0800 (PST) Received: from localhost ([95.144.14.233]) by smtp.gmail.com with ESMTPSA id b42sm3925153wrg.48.2018.01.04.09.38.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jan 2018 09:38:00 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Extra subreg fold for variable-length CONST_VECTORs Date: Thu, 04 Jan 2018 17:38:00 +0000 Message-ID: <87fu7la5jb.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 The SVE support for the new CONST_VECTOR encoding needs to be able to extract the first N bits of the vector and duplicate it. This patch adds a simplify_subreg rule for that. The code is covered by the gcc.target/aarch64/sve_slp_*.c tests. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also tested by comparing the before and after assembly output for at least one target per CPU directory. OK to install? Richard 2018-01-04 Richard Sandiford gcc/ * simplify-rtx.c (simplify_immed_subreg): Add an inner_bytes parameter and use it instead of GET_MODE_SIZE (innermode). Use inner_bytes * BITS_PER_UNIT instead of GET_MODE_BITSIZE (innermode). Use CEIL (inner_bytes, GET_MODE_UNIT_SIZE (innermode)) instead of GET_MODE_NUNITS (innermode). Also add a first_elem parameter. Change innermode from fixed_mode_size to machine_mode. (simplify_subreg): Update call accordingly. Handle a constant-sized subreg of a variable-length CONST_VECTOR. Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2018-01-03 21:42:44.569646782 +0000 +++ gcc/simplify-rtx.c 2018-01-04 17:35:25.747473457 +0000 @@ -5971,13 +5971,16 @@ simplify_ternary_operation (enum rtx_cod or CONST_FIXED or CONST_VECTOR, returning another CONST_INT or CONST_WIDE_INT or CONST_DOUBLE or CONST_FIXED or CONST_VECTOR. - Works by unpacking OP into a collection of 8-bit values + Works by unpacking INNER_BYTES bytes of OP into a collection of 8-bit values represented as a little-endian array of 'unsigned char', selecting by BYTE, - and then repacking them again for OUTERMODE. */ + and then repacking them again for OUTERMODE. If OP is a CONST_VECTOR, + FIRST_ELEM is the number of the first element to extract, otherwise + FIRST_ELEM is ignored. */ static rtx simplify_immed_subreg (fixed_size_mode outermode, rtx op, - fixed_size_mode innermode, unsigned int byte) + machine_mode innermode, unsigned int byte, + unsigned int first_elem, unsigned int inner_bytes) { enum { value_bit = 8, @@ -6007,13 +6010,13 @@ simplify_immed_subreg (fixed_size_mode o /* We support any size mode. */ max_bitsize = MAX (GET_MODE_BITSIZE (outermode), - GET_MODE_BITSIZE (innermode)); + inner_bytes * BITS_PER_UNIT); /* Unpack the value. */ if (GET_CODE (op) == CONST_VECTOR) { - num_elem = GET_MODE_NUNITS (innermode); + num_elem = CEIL (inner_bytes, GET_MODE_UNIT_SIZE (innermode)); elem_bitsize = GET_MODE_UNIT_BITSIZE (innermode); } else @@ -6030,7 +6033,7 @@ simplify_immed_subreg (fixed_size_mode o { unsigned char * vp; rtx el = (GET_CODE (op) == CONST_VECTOR - ? CONST_VECTOR_ELT (op, elem) + ? CONST_VECTOR_ELT (op, first_elem + elem) : op); /* Vectors are kept in target memory order. (This is probably @@ -6157,10 +6160,9 @@ simplify_immed_subreg (fixed_size_mode o /* Renumber BYTE so that the least-significant byte is byte 0. A special case is paradoxical SUBREGs, which shouldn't be adjusted since they will already have offset 0. */ - if (GET_MODE_SIZE (innermode) >= GET_MODE_SIZE (outermode)) + if (inner_bytes >= GET_MODE_SIZE (outermode)) { - unsigned ibyte = (GET_MODE_SIZE (innermode) - GET_MODE_SIZE (outermode) - - byte); + unsigned ibyte = inner_bytes - GET_MODE_SIZE (outermode) - byte; unsigned word_byte = WORDS_BIG_ENDIAN ? ibyte : byte; unsigned subword_byte = BYTES_BIG_ENDIAN ? ibyte : byte; byte = (subword_byte % UNITS_PER_WORD @@ -6169,7 +6171,7 @@ simplify_immed_subreg (fixed_size_mode o /* BYTE should still be inside OP. (Note that BYTE is unsigned, so if it's become negative it will instead be very large.) */ - gcc_assert (byte < GET_MODE_SIZE (innermode)); + gcc_assert (byte < inner_bytes); /* Convert from bytes to chunks of size value_bit. */ value_start = byte * (BITS_PER_UNIT / value_bit); @@ -6358,7 +6360,18 @@ simplify_subreg (machine_mode outermode, if (is_a (outermode, &fs_outermode) && is_a (innermode, &fs_innermode) && byte.is_constant (&cbyte)) - return simplify_immed_subreg (fs_outermode, op, fs_innermode, cbyte); + return simplify_immed_subreg (fs_outermode, op, fs_innermode, cbyte, + 0, GET_MODE_SIZE (fs_innermode)); + + /* Handle constant-sized outer modes and variable-sized inner modes. */ + unsigned HOST_WIDE_INT first_elem; + if (GET_CODE (op) == CONST_VECTOR + && is_a (outermode, &fs_outermode) + && constant_multiple_p (byte, GET_MODE_UNIT_SIZE (innermode), + &first_elem)) + return simplify_immed_subreg (fs_outermode, op, innermode, 0, + first_elem, + GET_MODE_SIZE (fs_outermode)); return NULL_RTX; }