From patchwork Mon Oct 23 17:33:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116829 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4897823qgn; Mon, 23 Oct 2017 10:34:18 -0700 (PDT) X-Received: by 10.98.209.8 with SMTP id z8mr13996230pfg.184.1508780058321; Mon, 23 Oct 2017 10:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508780058; cv=none; d=google.com; s=arc-20160816; b=EIk8rTogkKat0yflWmmbCAiPYIoRR0wNQ7Dc7ZKUPi81tIiHAGRqAK0YDK6ZcJIYcJ C/uvJ4UUCdcBTozQframhtlo5GuW53GX4cnxkKeRngDdFXDbFntSq8/G8h18r3HiA4kT WjK2O5i4RmCJCEe1l9pCRmTqdqQzjHLiCt7qu/CI1hSiD6roIzhQkxfwlHl21uoE0zRb Cf4JqvhNK2t57o747XC0oX5JQj5c56wKoQuHwQE00VRM1Gd2cmUm4+m71BwaV4606aNW 2TfpDamcOlDFOr/ilmrd5D5yGN3w9S8xIaueontkPgulkQ4xSDHw4cEIzB6Asexhdzs+ jdvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :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=S1jXU0wPRQjgfJG880mLhftMSyuOE2I0ga1ulVKXeHg=; b=g2NXz8G4GrtHlkA3owDUlRHQvdPA7Pzwn7v6KMyFTCS/FWmc9kwKkSD/br3wzbMN9x gjkdJZl++dvh5gcv8rf634Bv8EEUylFHCi/4pl+0zSjDAeQ0EvB7ZK3ksGth9tEVuMKH 1OTSnXW98ktBoUMvtwPHCsXHkgeWOvHDj9qE7jfY95KQVdPO0kmF52/T3V+GhzWBAo0q rJJmNraLmCssx4V2U8eq/zWk/Xq+Z0QBtnCvBx//yjqODb2RXJzQQdpKuEgntmlBDM4B IY2Pfa5yg96R+kbd6v1WrOYYMEJWgWcV5yjTezdrokOIUTeR31Trf2OL9GJ3oYpDU1HX 8CeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Ws37Mluf; spf=pass (google.com: domain of gcc-patches-return-464860-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464860-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 a13si5100327pgt.572.2017.10.23.10.34.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:34:18 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464860-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=Ws37Mluf; spf=pass (google.com: domain of gcc-patches-return-464860-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464860-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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=iuI9YIVmQBln6PFYG90aCvC/0IKDT 7OJa1ohBz3FHwgBBDVnDzlpaXaRwfKRLmQYmhabCp51vF/W5YCq+i5RCA1SYQLVN S1fOH+EO9X4mEWOtFQbykKJsY9JdKQ4zs/elbtnFlvOZBhXuZufOZpPwjqxK/xB4 f5vA3KeJqfkcxw= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=IdU6niXICk+oF+qO1UyjwCaZQkI=; b=Ws3 7MlufMf6JRpIrnwOdtKGmBHBkXwC5OMEF1m8drRfgLHxBhd0o30PdC3DJeYNni6B gGL+xTrXBVwQM4u6Cn/ZmzFA7jjB0c9br7drBq3xa3wKshuLaVQgSgDU2NN04P2G bdPixLXxA0DNhmVchxThtBRMA5YBo2xcSngnqBkk= Received: (qmail 59091 invoked by alias); 23 Oct 2017 17:34:05 -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 59076 invoked by uid 89); 23 Oct 2017 17:34:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 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= X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:34:03 +0000 Received: by mail-wm0-f44.google.com with SMTP id r68so11366978wmr.3 for ; Mon, 23 Oct 2017 10:34:03 -0700 (PDT) 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:references:date :in-reply-to:message-id:user-agent:mime-version; bh=S1jXU0wPRQjgfJG880mLhftMSyuOE2I0ga1ulVKXeHg=; b=mbw0U2mzJZLzYPH8FgulYx7zuzLDPG/bRVHSkSNxgrcKZaQi1QGMindQkuYwHojg7H UA+QF6MEbj/FmAAt/+f/0c0UZWrY0Mhgi052seV++n9Vc0Viukm5be4XIxByvi8V7RX6 HDwaxVQSr64DSYjsYLrP+/kw8jzJTsUhNHRn83UEYNpP78CgLtR7TZY8g2cuD6sHUqnU yVzoQKC0jZHY3/JBX/idpxQRl/v0lE5NMcIqES2AL5kZbEL2WqIaoqUWwOts3C1ajAho MoqFNug+EGstJi455S2BZFTj5a06mipjmnxF8zUJooYrnoPMPN0Oyg5EuMDCAT6QBVho XH5w== X-Gm-Message-State: AMCzsaWY6hkS2BLLtmUtvgYCrGXgUG5kyIxs4pAHPnNsDwlf1jaoeV7v OTZigCtYi4+5Nx+f9Er9xawK8nozhPA= X-Google-Smtp-Source: ABhQp+T5nKwyLTm9LZnp7vO2hgeieAnG27DwkTHorJMOuu8PzHRK6hfjdgp6qv4bQSOGNbxLB2l3vQ== X-Received: by 10.28.67.133 with SMTP id q127mr6524428wma.71.1508780040950; Mon, 23 Oct 2017 10:34:00 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id e131sm4758202wmg.15.2017.10.23.10.33.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:34:00 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [084/nnn] poly_int: folding BIT_FIELD_REFs on vectors References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:33:59 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87po9dg454.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes the: (BIT_FIELD_REF CONSTRUCTOR@0 @1 @2) folder cope with polynomial numbers of elements. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * match.pd: Cope with polynomial numbers of vector elements. Index: gcc/match.pd =================================================================== --- gcc/match.pd 2017-10-23 17:22:18.230825454 +0100 +++ gcc/match.pd 2017-10-23 17:22:50.031432167 +0100 @@ -4307,46 +4307,43 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) idx = idx / width; n = n / width; /* Constructor elements can be subvectors. */ - unsigned HOST_WIDE_INT k = 1; + poly_uint64 k = 1; if (CONSTRUCTOR_NELTS (ctor) != 0) { tree cons_elem = TREE_TYPE (CONSTRUCTOR_ELT (ctor, 0)->value); if (TREE_CODE (cons_elem) == VECTOR_TYPE) k = TYPE_VECTOR_SUBPARTS (cons_elem); } + unsigned HOST_WIDE_INT elt, count, const_k; } (switch /* We keep an exact subset of the constructor elements. */ - (if ((idx % k) == 0 && (n % k) == 0) + (if (multiple_p (idx, k, &elt) && multiple_p (n, k, &count)) (if (CONSTRUCTOR_NELTS (ctor) == 0) { build_constructor (type, NULL); } - (with + (if (count == 1) + (if (elt < CONSTRUCTOR_NELTS (ctor)) + { CONSTRUCTOR_ELT (ctor, elt)->value; } + { build_zero_cst (type); }) { - idx /= k; - n /= k; - } - (if (n == 1) - (if (idx < CONSTRUCTOR_NELTS (ctor)) - { CONSTRUCTOR_ELT (ctor, idx)->value; } - { build_zero_cst (type); }) - { - vec *vals; - vec_alloc (vals, n); - for (unsigned i = 0; - i < n && idx + i < CONSTRUCTOR_NELTS (ctor); ++i) - CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE, - CONSTRUCTOR_ELT (ctor, idx + i)->value); - build_constructor (type, vals); - })))) + vec *vals; + vec_alloc (vals, count); + for (unsigned i = 0; + i < count && elt + i < CONSTRUCTOR_NELTS (ctor); ++i) + CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE, + CONSTRUCTOR_ELT (ctor, elt + i)->value); + build_constructor (type, vals); + }))) /* The bitfield references a single constructor element. */ - (if (idx + n <= (idx / k + 1) * k) + (if (k.is_constant (&const_k) + && idx + n <= (idx / const_k + 1) * const_k) (switch - (if (CONSTRUCTOR_NELTS (ctor) <= idx / k) + (if (CONSTRUCTOR_NELTS (ctor) <= idx / const_k) { build_zero_cst (type); }) - (if (n == k) - { CONSTRUCTOR_ELT (ctor, idx / k)->value; }) - (BIT_FIELD_REF { CONSTRUCTOR_ELT (ctor, idx / k)->value; } - @1 { bitsize_int ((idx % k) * width); }))))))))) + (if (n == const_k) + { CONSTRUCTOR_ELT (ctor, idx / const_k)->value; }) + (BIT_FIELD_REF { CONSTRUCTOR_ELT (ctor, idx / const_k)->value; } + @1 { bitsize_int ((idx % const_k) * width); }))))))))) /* Simplify a bit extraction from a bit insertion for the cases with the inserted element fully covering the extraction or the insertion