From patchwork Mon Nov 6 09:10:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 118013 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2542306qgn; Mon, 6 Nov 2017 01:10:44 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q5z/RJioVpM5ye449Abxqyf9+Mpar8+FQ9UFzKXUkdas70nEkWA6ZcEiFR0t29sc2tbS06 X-Received: by 10.159.198.8 with SMTP id f8mr14370078plo.209.1509959444458; Mon, 06 Nov 2017 01:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509959444; cv=none; d=google.com; s=arc-20160816; b=Fm+MoQqcauSQonYcvP224ouglC62JXLsWS6EIbbU5HGHJeCbVqBi+UWVGCP3BVcUP9 FfllQZ8NmllgtEO3GvcwuC85a4vhhsyIlKWWsP8nFv2Aq8lkPvNZb1J68p2yxBc08ZOc qngQd8WrfDanrdUdeaO+1S4/jAE7KgM0xLjasb/YS5OHZibc01zEcIRmBHIoS2uJl00l 6gtqNT/qI2d9vGNpPe0z0Y/cNnGgl4o9R0Jyc09VYnLmRlXn47r6oCLThT29RnZivb5U JislMZyOiK4Mgvg29WF43wPFC3iSLGoO0IJuhLlwGxDAqARjc3DGOfgRwfE1PXAkQ8JG LqrA== 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=AxSefVAIL+uRsJk2kYNXkwuP49S7PE/UacxiiK34+IY=; b=DOlx9zEUf/ng/0UCtOD4bZgoEoUl3uSC/qPHxGnoKBAAw+iQVYs4TuW3mmLdNHE7wH j6FAVwGuhaI8NTkHFjLkabNFElf/rZZ0ADgRzGuRnAlTvymaaHD6qO0Wo1QwUGnVOIWa h8JbDvRM0nk0hf0qYBYvzArYnCn9bLAfJNntEA6GKeTG18T4UFSAj0VY3Y3mKaYFFQfm TorFu0u0vNaRiHQc4NNUA95apuBeVsN6Ry1h3e7ZYNiBYl5ZOb9eg6T70u/J9RS25sox 9JjHBpunEMbeYWd2x62GRdJJ3DmixK30vZz63Gd7plRIBrb+sMZvwteMbTEklCUzTuB0 F0dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=jW4O5D+L; spf=pass (google.com: domain of gcc-patches-return-465996-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-465996-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 q1si9664311plb.404.2017.11.06.01.10.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 01:10:44 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-465996-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=jW4O5D+L; spf=pass (google.com: domain of gcc-patches-return-465996-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-465996-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=UQUD/WBTYtMc0t5Zz3gg8EI3QMVB5MMgVmmjPxIhf0MjIjk2lQPeR +RbvoIX+bpRyfWwyomyi1EZMY73eWLSdHqMKeU3v7NwHVnGgDrWTLm66q/wNmMZG 8ksgOAixBe4CTqaUOlcgq1g7tIc2zq11YZYkXoRhpzUiF4h260zBXQ= 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=zK9E9rnp5ClYLd+/+pXGZOlM7nU=; b=jW4O5D+LcrTT7XpQ0IPF 4pJeSBuDN1N9T8Vlc/Kdxz4uR3kbAhJkUxbiebjAti1KPIyUV/JYLoUHu2YYprTl oVbxkFGW8cdLK6Mq7TnnOWpqmI5a9CISF8XFCrOVUbP9rz2AWuaLTB5hMKv2qBNC Ay2H8yPwUgoRezzBLIXUORU= Received: (qmail 44545 invoked by alias); 6 Nov 2017 09:10:32 -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 44536 invoked by uid 89); 6 Nov 2017 09:10:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=honour, (unknown), stand 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; Mon, 06 Nov 2017 09:10:26 +0000 Received: by mail-wr0-f174.google.com with SMTP id l8so7842916wre.12 for ; Mon, 06 Nov 2017 01:10:26 -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=AxSefVAIL+uRsJk2kYNXkwuP49S7PE/UacxiiK34+IY=; b=YagrHae0PJwruhPdIPtC9foitDyFOLV3GMw6WYOaQEwGL3Wa55WhNntjSxcUkAy95a CnHLJ7IhHGU0buzF0SJAlVTkbB2gAxg4ARpHjb80oK/Gczpyq+0q1Wkp0z40Z4X5HiIz nZNZcS/8XBALFCahtNntiySnvLyzBOF+grrl+Gke5+BZX2cGsu38aYPtPAqlpCdWioTm OjuHlnv8pC4fmE7Srgr8z7Z+hFTN7oxM1eNvGViR9Omu72vm0CoiqpT4/Ro9HyFA+caF mbhe1ZSRuiJ/xgs1NQGnSU21DkbVLvuvPXhFGbmfNaXn8Dv/LXgFm0mV4HgXh96Hfowb 9wpQ== X-Gm-Message-State: AMCzsaVNOe5y3JT4balEbkGjYKPK86vtscv8eJMqZ3ESDcb61PPLe+W5 BihRYmQn7TmSYMMNJwh3zkM3wXfnDNQ= X-Received: by 10.223.185.77 with SMTP id b13mr12807226wrg.58.1509959424044; Mon, 06 Nov 2017 01:10:24 -0800 (PST) Received: from localhost ([2.25.234.120]) by smtp.gmail.com with ESMTPSA id a34sm11440569wra.64.2017.11.06.01.10.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2017 01:10:23 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Be stricter about CONST_VECTOR operands Date: Mon, 06 Nov 2017 09:10:23 +0000 Message-ID: <87inenydq8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The recent gen_vec_duplicate patches used CONST_VECTOR for all constants, but the documentation says: @findex const_vector @item (const_vector:@var{m} [@var{x0} @var{x1} @dots{}]) Represents a vector constant. The square brackets stand for the vector containing the constant elements. @var{x0}, @var{x1} and so on are the @code{const_int}, @code{const_double} or @code{const_fixed} elements. Both the AArch32 and AArch64 ports relied on the elements having this form and would ICE if the element was something like a CONST instead. This showed up as a failure in vect-102.c for both arm-eabi and aarch64-elf (but not aarch64-linux-gnu, which is what the series was tested on). The two obvious options were to redefine CONST_VECTOR to accept all constants or make gen_vec_duplicate honour the existing documentation. It looks like other code also assumes that integer CONST_VECTORs contain CONST_INTs, so the patch does the latter. I deliberately didn't add an assert to gen_const_vec_duplicate because it looks like the SPU port *does* expect to be able to create CONST_VECTORs of symbolic constants. Also, I think the list above should include const_wide_int for vectors of TImode and wider. The new routine takes a mode for consistency with the generators, and because I think it does make sense to accept all constants for variable-length: (const (vec_duplicate ...)) rather than have some rtxes for which we instead use: (vec_duplicate (const ...)) Tested on aarch64-elf, aarch64-linux-gnu, x86_64-linux-gnu and powerpc64-linux-gnu. OK to install? Richard 2017-11-06 Richard Sandiford gcc/ * doc/rtl.texi (const_vector): Say that elements can be const_wide_ints too. * emit-rtl.h (valid_for_const_vec_duplicate_p): Declare. * emit-rtl.c (valid_for_const_vec_duplicate_p): New function. (gen_vec_duplicate): Use it instead of CONSTANT_P. * optabs.c (expand_vector_broadcast): Likewise. Index: gcc/doc/rtl.texi =================================================================== --- gcc/doc/rtl.texi 2017-11-06 08:56:27.608223621 +0000 +++ gcc/doc/rtl.texi 2017-11-06 09:01:44.150672938 +0000 @@ -1625,7 +1625,8 @@ accessed with @code{CONST_FIXED_VALUE_LO @item (const_vector:@var{m} [@var{x0} @var{x1} @dots{}]) Represents a vector constant. The square brackets stand for the vector containing the constant elements. @var{x0}, @var{x1} and so on are -the @code{const_int}, @code{const_double} or @code{const_fixed} elements. +the @code{const_int}, @code{const_wide_int}, @code{const_double} or +@code{const_fixed} elements. The number of units in a @code{const_vector} is obtained with the macro @code{CONST_VECTOR_NUNITS} as in @code{CONST_VECTOR_NUNITS (@var{v})}. Index: gcc/emit-rtl.h =================================================================== --- gcc/emit-rtl.h 2017-11-06 08:56:27.157323659 +0000 +++ gcc/emit-rtl.h 2017-11-06 09:01:44.151672938 +0000 @@ -438,6 +438,7 @@ get_max_uid (void) return crtl->emit.x_cur_insn_uid; } +extern bool valid_for_const_vec_duplicate_p (machine_mode, rtx); extern rtx gen_const_vec_duplicate (machine_mode, rtx); extern rtx gen_vec_duplicate (machine_mode, rtx); Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-11-06 08:56:27.608223621 +0000 +++ gcc/emit-rtl.c 2017-11-06 09:01:44.151672938 +0000 @@ -5757,6 +5757,17 @@ init_emit (void) #endif } +/* Return true if X is a valid element for a duplicated vector constant + of the given mode. */ + +bool +valid_for_const_vec_duplicate_p (machine_mode, rtx x) +{ + return (CONST_SCALAR_INT_P (x) + || CONST_DOUBLE_AS_FLOAT_P (x) + || CONST_FIXED_P (x)); +} + /* Like gen_const_vec_duplicate, but ignore const_tiny_rtx. */ static rtx @@ -5792,7 +5803,7 @@ gen_const_vec_duplicate (machine_mode mo rtx gen_vec_duplicate (machine_mode mode, rtx x) { - if (CONSTANT_P (x)) + if (valid_for_const_vec_duplicate_p (mode, x)) return gen_const_vec_duplicate (mode, x); return gen_rtx_VEC_DUPLICATE (mode, x); } Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-11-06 08:56:27.466923633 +0000 +++ gcc/optabs.c 2017-11-06 09:01:44.152672938 +0000 @@ -377,7 +377,7 @@ expand_vector_broadcast (machine_mode vm gcc_checking_assert (VECTOR_MODE_P (vmode)); - if (CONSTANT_P (op)) + if (valid_for_const_vec_duplicate_p (vmode, op)) return gen_const_vec_duplicate (vmode, op); /* ??? If the target doesn't have a vec_init, then we have no easy way