From patchwork Sat Dec 9 23:24:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 121300 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1167038qgn; Sat, 9 Dec 2017 15:24:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMZi+HHH35RUutnPwbtYfLZask1y5PEsQJAW75yWQ6wz0BqtPiiXU05mqYjz+s7sS5LQd3IC X-Received: by 10.98.209.8 with SMTP id z8mr2867357pfg.113.1512861889366; Sat, 09 Dec 2017 15:24:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512861889; cv=none; d=google.com; s=arc-20160816; b=UDtBGwOKvktuSEVjYjgKavZEohLUqjC+aHs2BlOHEUSUM403dZYlp1+f2yObEkzLZr MMFqImooWeUOIqoj0MChV/peTqDld/ypWjYzLsJreXc8IGI2NkDQjGVj4Swo9TWq7OYs Vt1xpnf4isFjAfGO2NQ96BxatoABQAGuoU4TMLcIthiJn466Zz5rz9wk7eC68DUpCLJZ Z9VdVtJ1thTiZg4htfV/KLNGpZXRG3J3TsHNlK6AhFMz/xFQ+C98Qo9GTCQZV28g6IVn HMWWW5W0PlR3jFsis5PIUwMC7ehlMKjHUwYum02zjsS3bNcfjG93r/jEgj/KEZfTkAyH t8qQ== 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=nM1FbpE5Z6D2JHZKqUBjK/FCHKH98Z63Nyrh+Tl7H/E=; b=dy4sFs+8RR78rTzSRlaS2mfQkckdReVIYJnZsidad3xm5bPKm3SSUUQcCBC556pBqP woNx9nu6ijcike2H1qZcrDiIZUzr5EEQbQdR+l4Rn8qW3er50jp1OU2LGruHg1VdsLF3 gMiBxEz+lZ0l6xzvyLwB9UQq/hlUb70R4wX8aGzzn12klEdw7e51FYqtiStaH1tK+F9w OGdaUILf2Nw/YAPRaURE3goutL4H0cUz/5wHaDES0PJV4Gi+CA9aZNG696NBrbO82xTu 73en0kAWjZ50IARN7dSPU4bIEtlXUBPs9TyNQLv/kmkZa+PmiD7JbPVHyaZ6E0tBc8cz 4hGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sjDzrisk; spf=pass (google.com: domain of gcc-patches-return-468861-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-468861-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 o7si7794817pgn.202.2017.12.09.15.24.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Dec 2017 15:24:49 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-468861-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=sjDzrisk; spf=pass (google.com: domain of gcc-patches-return-468861-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-468861-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=lsr/gOBemPy5YtoA3aAsKGzYEh2RZ X7k8QU0FylX5l2WzjMwYuvItDG0YyliJM+LRyZq7fF/gfQspcMaIZ9dKCkn68+Q3 NbEGzK1KA8guD4rcxfyR+Ir1UsvjEOcF/HcX9Glyu+YNSW1+qUh+zsUqe7Z0ui82 IBpSfzPGM7cL3w= 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=2e29zrSN7gtWQ6nf/aTb0Y44apg=; b=sjD zriskQzJ68Ca0pmV73OGS2R1bMqgEztJFN3mFT3+gTTNy/kjCFetmJ7S5vn0vi6A +C7lr4doiCfKhqP/+c6Qpb9mVzfkzrrb7bRtvKy+snFVf8GEREeOy0UW1t21DNLc FdY3B/FW4e5bGCz6LCL7sOLM8VvPFxWCsP7ir2o4= Received: (qmail 108425 invoked by alias); 9 Dec 2017 23:24:36 -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 108367 invoked by uid 89); 9 Dec 2017 23:24:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 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-wr0-f174.google.com Received: from mail-wr0-f174.google.com (HELO mail-wr0-f174.google.com) (209.85.128.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Dec 2017 23:24:15 +0000 Received: by mail-wr0-f174.google.com with SMTP id v22so14051198wrb.0 for ; Sat, 09 Dec 2017 15:24:08 -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:references:date :in-reply-to:message-id:user-agent:mime-version; bh=nM1FbpE5Z6D2JHZKqUBjK/FCHKH98Z63Nyrh+Tl7H/E=; b=oaG51XKYqugu4U9RBRVE0JiIn41AjET1LljYNAA9nG8SwdSjsEJ8jBhdwHpg6Z66k5 B7UdsutEGE/1YdaqMEuiRVe0U2npzbplRAnR2TLKp9uW8Ie6J4BzKFs46DQA6nlPB3pk kpAx77NjP8mq3MRweXJ9NWc3PxbD5nlvHayGq5BqaCb2XWX5UGbohoVzslRrzy45GFmM ikvYBDaWnLDh4PF+7Wz84vB3b4zZPc0FqNlZcf1dBgaJ1+jorgXEcpliKVgPULqP4/xJ spAGkEFKIPj3hDreLoPeqEtVF8WRQidXa0pbM1Bx1v8r5F+3baaemfjxLNyB54kSyujy LT8g== X-Gm-Message-State: AJaThX5UpcHVC91YzP8q9aD8JGtcoCWGCbQ/xm2Tr3/k6uSfIGvsIaYy YvyS3UB2f3pM4UY0pB3TNtyjX8AKWjM= X-Received: by 10.223.151.197 with SMTP id t5mr28550016wrb.263.1512861846330; Sat, 09 Dec 2017 15:24:06 -0800 (PST) Received: from localhost ([2.25.234.120]) by smtp.gmail.com with ESMTPSA id n32sm13880726wrb.62.2017.12.09.15.24.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Dec 2017 15:24:05 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [11/13] Use vec_perm_builder::series_p in shift_amt_for_vec_perm_mask References: <87indfmrgt.fsf@linaro.org> <877etvlc4g.fsf@linaro.org> Date: Sat, 09 Dec 2017 23:24:05 +0000 In-Reply-To: <877etvlc4g.fsf@linaro.org> (Richard Sandiford's message of "Sat, 09 Dec 2017 23:23:11 +0000") Message-ID: <871sk3lc2y.fsf_-_@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch makes shift_amt_for_vec_perm_mask use series_p to check for the simple case of a natural linear series before falling back to testing each element individually. The series_p test works with variable-length vectors but testing every individual element doesn't. 2017-12-09 Richard Sandiford gcc/ * optabs.c (shift_amt_for_vec_perm_mask): Try using series_p before testing each element individually. Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-12-09 22:48:52.266015836 +0000 +++ gcc/optabs.c 2017-12-09 22:48:56.257154317 +0000 @@ -5375,20 +5375,20 @@ vector_compare_rtx (machine_mode cmp_mod static rtx shift_amt_for_vec_perm_mask (machine_mode mode, const vec_perm_indices &sel) { - unsigned int i, first, nelt = GET_MODE_NUNITS (mode); + unsigned int nelt = GET_MODE_NUNITS (mode); unsigned int bitsize = GET_MODE_UNIT_BITSIZE (mode); - - first = sel[0]; + unsigned int first = sel[0]; if (first >= nelt) return NULL_RTX; - for (i = 1; i < nelt; i++) - { - int idx = sel[i]; - unsigned int expected = i + first; - /* Indices into the second vector are all equivalent. */ - if (idx < 0 || (MIN (nelt, (unsigned) idx) != MIN (nelt, expected))) - return NULL_RTX; - } + + if (!sel.series_p (0, 1, first, 1)) + for (unsigned int i = 1; i < nelt; i++) + { + unsigned int expected = i + first; + /* Indices into the second vector are all equivalent. */ + if (MIN (nelt, sel[i]) != MIN (nelt, expected)) + return NULL_RTX; + } return GEN_INT (first * bitsize); }