From patchwork Wed Jan 3 08:59:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 123283 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9929073qgn; Wed, 3 Jan 2018 01:00:08 -0800 (PST) X-Google-Smtp-Source: ACJfBoveifgZTJ6EG/sERmLoJmoYkedmJ7+qVqm4dgvXyoJOwYbHEj5ryvWfLBdrXjJh9xpZh3rZ X-Received: by 10.99.95.198 with SMTP id t189mr679804pgb.66.1514970008454; Wed, 03 Jan 2018 01:00:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514970008; cv=none; d=google.com; s=arc-20160816; b=nZgVtbMuEaAZranIUeWIL9IFIxCTHHZZiXKl/ovtCDK8j/dT8hyAh18yj0eRFBjKrx kGp8XZR1LOD6vV4DyJZGoi6NBt1p/gKnMviBEsC/Vd0MdO+sB4+xbkHvOUSW7l6EemJv M5YwTFXTgI/kpmUQaMjJoFQIpC3Xjbptqv+9xu0a2CCAN5JwrByd1QXHhZdynj0sNYmz WRL8VtQ07Gb8DaxmrUh6w0hKEBuU4HhRKa2KhWYAUlIwQ98w7nbcktcY6rpDY2RtGDVS IswszMZc3dQ1iJzfSo0mbTbYNJ7ov+OyDJBGqIGDXBXZ/ED1Q7hyRClPxAZMoRRg2Har 9TlA== 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=BtrcJemPNQ6Oku8kITND0MByLph5UNIC3J3LlPEkHss=; b=rtoRz28ZKE8CvmJuoGcilw+ApLOu28lTI/uBbduG8Q5fuW1FjIV8fDGNQdiqpCAaYT KCmxNF0DnRYNXhbJ4ejUqeA9jYWSXakxYfnWTeWcwhbXE6CAAilsBRwx8wXL4OVRDxxV WbCxHP5Dq35v7ItpvjA6XjrMY+LYu5rwBmVCUL+UyMYaWum1yr6SXIJx9XqivQvSfFTA vpFjV1ki1WDGCutH0bryFlk4ExASE6FAwtDZdoKouw1mJ0CRL7b2XWUuI6Lo9PCjOGvA tRr1R6l1vhqgArCmvSVLaMncVHTsQ9X0Ad2djKs18nO3CLRBwsik8OAJwZvGHvHaSWMb EkvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gQjyrc1i; spf=pass (google.com: domain of gcc-patches-return-470029-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470029-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 p3si423868pld.717.2018.01.03.01.00.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 01:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-470029-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=gQjyrc1i; spf=pass (google.com: domain of gcc-patches-return-470029-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470029-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=TCAmGey71L96MOkSF/F4VOYoH3Dn6i3GSI2beDfVGpMt+RRHrSEii /KwFhI/6YOkGZGLwE9Bed+BoFqO3h7vZeRDguljhPF0k/9xZrdlfCxUvKk5C/FcO h7E1QiZX9ogBaXDoGZiZb7/FJI5DLPlLxmvVqYhDbTwNimg1fqL1A8= 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=Df0jhT95j0yHYgQB/1N6vkWxzpU=; b=gQjyrc1ifBT52lpoEt2E NSMKz1JaU+eFHK/51QkDHr/ILI/HpQbQLr5Yh4bhOEts3uRV2A0z0R5Xv7a/cRFS TWOLnWb+Vz1zUNyfiaXTdKkJXK1k598QKUPicUa8YKm+Nzd2i+0fD5+X3a+1kmot a5KcAaFpMWuarr6tN8nGFKc= Received: (qmail 35299 invoked by alias); 3 Jan 2018 08:59:53 -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 35287 invoked by uid 89); 3 Jan 2018 08:59:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 Jan 2018 08:59:49 +0000 Received: by mail-wm0-f49.google.com with SMTP id b141so1396946wme.1 for ; Wed, 03 Jan 2018 00:59:48 -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=BtrcJemPNQ6Oku8kITND0MByLph5UNIC3J3LlPEkHss=; b=rZrwDOw7cgyLBgx/IlYaWxOXHfq5hHWCPHJIKAsTHZ3xV+RzJg6u7yk+YGnggHhmXc oHyQlg585Pfjy2WVhf2tfheezKBfCZSNmbjqbvKGB90+0JKOzOR608X1jaUItNHybDMj sxXMYAFo/nuxwey8OhQc8T72wDiNcKUb14mxEqPnM/pwDU8IfZwtpZvzt3/ZuKS0iJxO ml5+YvO7nOiZYL+eEW68Ehch+JxuyFcKALbVAKxBvs4Me8gFvpKY1icNK2rUFLDdYkyo d+WXKzoxBGL0hBTQZBfYIpa2d8DK5JzdCeYrKiIO077+x59o4VBCL9siM217aZkWy5Bl HscA== X-Gm-Message-State: AKGB3mLZjgML8CxwdQcGEB2OY7KWNdS5fD8Td23bSLygrBn6Ks/tK4PR j3wuvuyF/uGOjV49QeAWH4QtiikH8gE= X-Received: by 10.28.69.136 with SMTP id l8mr737101wmi.19.1514969986590; Wed, 03 Jan 2018 00:59:46 -0800 (PST) Received: from localhost (188.29.165.215.threembb.co.uk. [188.29.165.215]) by smtp.gmail.com with ESMTPSA id m18sm913400wmc.18.2018.01.03.00.59.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jan 2018 00:59:45 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [committed] [100.1/nnn] poly_int: vec_perm_indices element type Date: Wed, 03 Jan 2018 08:59:39 +0000 Message-ID: <87tvw3mi6c.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch changes the vec_perm_indices element type from HOST_WIDE_INT to poly_int64, so that it can represent indices into a variable-length vector. 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. Committed as pre-approved by Jeff here: https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01409.html . Thanks, Richard 2018-01-03 Richard Sandiford gcc/ * vec-perm-indices.h (vec_perm_builder): Change element type from HOST_WIDE_INT to poly_int64. (vec_perm_indices::element_type): Update accordingly. (vec_perm_indices::clamp): Handle polynomial element_types. * vec-perm-indices.c (vec_perm_indices::series_p): Likewise. (vec_perm_indices::all_in_range_p): Likewise. (tree_to_vec_perm_builder): Check for poly_int64 trees rather than shwi trees. * vector-builder.h (vector_builder::stepped_sequence_p): Handle polynomial vec_perm_indices element types. * int-vector-builder.h (int_vector_builder::equal_p): Likewise. * fold-const.c (fold_vec_perm): Likewise. * optabs.c (shift_amt_for_vec_perm_mask): Likewise. * tree-vect-generic.c (lower_vec_perm): Likewise. * tree-vect-slp.c (vect_transform_slp_perm_load): Likewise. * config/aarch64/aarch64.c (aarch64_evpc_tbl): Cast d->perm element type to HOST_WIDE_INT. Index: gcc/vec-perm-indices.h =================================================================== --- gcc/vec-perm-indices.h 2018-01-02 18:27:07.346639775 +0000 +++ gcc/vec-perm-indices.h 2018-01-03 08:46:30.347663443 +0000 @@ -25,7 +25,7 @@ #define GCC_VEC_PERN_INDICES_H 1 /* A vector_builder for building constant permutation vectors. The elements do not need to be clamped to a particular range of input elements. */ -typedef int_vector_builder vec_perm_builder; +typedef int_vector_builder vec_perm_builder; /* This class represents a constant permutation vector, such as that used as the final operand to a VEC_PERM_EXPR. @@ -49,7 +49,7 @@ typedef int_vector_builder= size) + if (!known_in_range_p (m_encoding[i], start, size)) return false; /* For stepped encodings, check the full range of the series. */ @@ -174,8 +174,11 @@ vec_perm_indices::all_in_range_p (elemen wide enough for overflow not to be a problem. */ element_type headroom_down = base1 - start; element_type headroom_up = size - headroom_down - 1; - if (headroom_up < step * step_nelts - && headroom_down < (limit - step) * step_nelts) + HOST_WIDE_INT diff; + if ((!step.is_constant (&diff) + || maybe_lt (headroom_up, diff * step_nelts)) + && (!(limit - step).is_constant (&diff) + || maybe_lt (headroom_down, diff * step_nelts))) return false; } } @@ -191,14 +194,14 @@ tree_to_vec_perm_builder (vec_perm_build { unsigned int encoded_nelts = vector_cst_encoded_nelts (cst); for (unsigned int i = 0; i < encoded_nelts; ++i) - if (!tree_fits_shwi_p (VECTOR_CST_ENCODED_ELT (cst, i))) + if (!tree_fits_poly_int64_p (VECTOR_CST_ENCODED_ELT (cst, i))) return false; builder->new_vector (TYPE_VECTOR_SUBPARTS (TREE_TYPE (cst)), VECTOR_CST_NPATTERNS (cst), VECTOR_CST_NELTS_PER_PATTERN (cst)); for (unsigned int i = 0; i < encoded_nelts; ++i) - builder->quick_push (tree_to_shwi (VECTOR_CST_ENCODED_ELT (cst, i))); + builder->quick_push (tree_to_poly_int64 (VECTOR_CST_ENCODED_ELT (cst, i))); return true; } Index: gcc/vector-builder.h =================================================================== --- gcc/vector-builder.h 2018-01-02 18:27:07.346639775 +0000 +++ gcc/vector-builder.h 2018-01-03 08:46:30.347663443 +0000 @@ -284,7 +284,8 @@ vector_builder::stepped_sequ || !derived ()->integral_p (elt3)) return false; - if (derived ()->step (elt1, elt2) != derived ()->step (elt2, elt3)) + if (maybe_ne (derived ()->step (elt1, elt2), + derived ()->step (elt2, elt3))) return false; if (!derived ()->can_elide_p (elt3)) Index: gcc/int-vector-builder.h =================================================================== --- gcc/int-vector-builder.h 2018-01-02 18:26:37.619823164 +0000 +++ gcc/int-vector-builder.h 2018-01-03 08:46:30.345663760 +0000 @@ -66,7 +66,7 @@ int_vector_builder::int_vector_builde inline bool int_vector_builder::equal_p (T elt1, T elt2) const { - return elt1 == elt2; + return known_eq (elt1, elt2); } /* Return the value of element ELT2 minus the value of element ELT1. */ Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2018-01-03 07:17:07.401983352 +0000 +++ gcc/fold-const.c 2018-01-03 08:46:30.345663760 +0000 @@ -8945,9 +8945,12 @@ fold_vec_perm (tree type, tree arg0, tre tree_vector_builder out_elts (type, nelts, 1); for (i = 0; i < nelts; i++) { - if (!CONSTANT_CLASS_P (in_elts[sel[i]])) + HOST_WIDE_INT index; + if (!sel[i].is_constant (&index)) + return NULL_TREE; + if (!CONSTANT_CLASS_P (in_elts[index])) need_ctor = true; - out_elts.quick_push (unshare_expr (in_elts[sel[i]])); + out_elts.quick_push (unshare_expr (in_elts[index])); } if (need_ctor) Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2018-01-02 18:27:52.375765255 +0000 +++ gcc/optabs.c 2018-01-03 08:46:30.346663602 +0000 @@ -5398,16 +5398,18 @@ shift_amt_for_vec_perm_mask (machine_mod { unsigned int nelt = GET_MODE_NUNITS (mode); unsigned int bitsize = GET_MODE_UNIT_BITSIZE (mode); - unsigned int first = sel[0]; - if (first >= nelt) + poly_int64 first = sel[0]; + if (maybe_ge (sel[0], nelt)) return NULL_RTX; if (!sel.series_p (0, 1, first, 1)) for (unsigned int i = 1; i < nelt; i++) { - unsigned int expected = i + first; + poly_int64 expected = i + first; /* Indices into the second vector are all equivalent. */ - if (MIN (nelt, sel[i]) != MIN (nelt, expected)) + if (maybe_lt (sel[i], nelt) + ? maybe_ne (sel[i], expected) + : maybe_lt (expected, nelt)) return NULL_RTX; } Index: gcc/tree-vect-generic.c =================================================================== --- gcc/tree-vect-generic.c 2018-01-03 07:16:49.037017897 +0000 +++ gcc/tree-vect-generic.c 2018-01-03 08:46:30.346663602 +0000 @@ -1337,18 +1337,19 @@ lower_vec_perm (gimple_stmt_iterator *gs != CODE_FOR_nothing && TREE_CODE (vec1) == VECTOR_CST && initializer_zerop (vec1) - && indices[0] - && indices[0] < elements) + && maybe_ne (indices[0], 0) + && known_lt (indices[0], elements)) { bool ok_p = indices.series_p (0, 1, indices[0], 1); if (!ok_p) { for (i = 1; i < elements; ++i) { - unsigned int expected = i + indices[0]; + poly_int64 expected = i + indices[0]; /* Indices into the second vector are all equivalent. */ - if (MIN (elements, (unsigned) indices[i]) - != MIN (elements, expected)) + if (maybe_lt (indices[i], elements) + ? maybe_ne (indices[i], expected) + : maybe_lt (expected, elements)) break; } ok_p = i == elements; Index: gcc/tree-vect-slp.c =================================================================== --- gcc/tree-vect-slp.c 2018-01-03 07:16:36.566760459 +0000 +++ gcc/tree-vect-slp.c 2018-01-03 08:46:30.347663443 +0000 @@ -3727,8 +3727,10 @@ vect_transform_slp_perm_load (slp_tree n vect_location, "unsupported vect permute { "); for (i = 0; i < nunits; ++i) - dump_printf (MSG_MISSED_OPTIMIZATION, - HOST_WIDE_INT_PRINT_DEC " ", mask[i]); + { + dump_dec (MSG_MISSED_OPTIMIZATION, mask[i]); + dump_printf (MSG_MISSED_OPTIMIZATION, " "); + } dump_printf (MSG_MISSED_OPTIMIZATION, "}\n"); } gcc_assert (analyze_only); Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2018-01-03 07:14:58.947066762 +0000 +++ gcc/config/aarch64/aarch64.c 2018-01-03 08:46:30.343664078 +0000 @@ -13625,7 +13625,7 @@ aarch64_evpc_tbl (struct expand_vec_perm mode on NEON. Reverse the index within each word but not the word itself. */ rperm[i] = GEN_INT (BYTES_BIG_ENDIAN ? d->perm[i] ^ (nunits - 1) - : d->perm[i]); + : (HOST_WIDE_INT) d->perm[i]); } sel = gen_rtx_CONST_VECTOR (vmode, gen_rtvec_v (nelt, rperm)); sel = force_reg (vmode, sel);