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: 829510 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-464860-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gzxwnS5v"; 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 3yLNn06t0Dz9t6Y for ; Tue, 24 Oct 2017 04:34:12 +1100 (AEDT) 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=fw9xiHtPFDL9Qxsger0Da8/teheOH /s2WXnm7J5NSd90VRMds/uODowjkscOVMyWmEHanD/T+Nab1BiOyFK+O5ePq/uPV 6wPUqWx5xylzMCf0ZnBf/ywLRIHx9a+42BowBX5P9KZxf1bK6e8D16jWPvztxXkE iUpEUL66bY4lpE= 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=gzx wnS5vC9qxmObyY286vaHc6huqT2hF8sKEWLKgloacO/XNLUPKEJyWkFlAJtwKVpg tCIss23LMmnD3JmDM4TN6SjGeeDVsReD3B4kybMJm1rrHCyjyt8YGbSMll41C7gK jtjTD66MgpFXVtswTmRbflKiypviEZLzrXw/Sj1U= 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