From patchwork Wed Dec 6 15:28:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 120872 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7192875qgn; Wed, 6 Dec 2017 07:28:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMZjNzxPLSonlOhVWDqWjkKsMyuB40qBl3o6xs2Zbm3Xf92+6gJGUhELw0O7D5v8x5svsz88 X-Received: by 10.159.198.67 with SMTP id y3mr1454665plt.263.1512574106927; Wed, 06 Dec 2017 07:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512574106; cv=none; d=google.com; s=arc-20160816; b=rcou9vgKVcKHyoDR7Ka+VGxrxTVbah5Nk99ihdmg97kvrcKiFBUp6sfPndwmE+b8oT mdoeS38hlIIqBNQqQvjNZGxTuvMt87rFaVdygysQ5ok8ikpDcYGt/GBZNOvTqXo6VDJ2 tpS/gjY0cooSGb0F10lPWvs85WKrkqYg9bLRSLDqL5g1soDWHue6Xtx8/bWV7G2eYXZm OlD7Qe4M1zjmNvEsL7zVMF35zBJyLuDloSscHcQEAn8TtYVNg0d0MWnMHmvAu1uYKWgY 1EOv7hekljK8OSLoGJ4QspUAlc24nBjN9rK1Sxgm5R1wv3qd9fz5OidvnI/y/NI5F4FE qgSA== 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:cc: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=yEegNSsKhtruUnLoPxSFGfv/09TP9zhIFUc5XLF2rDI=; b=T4Xx+DqGK6pqnP8/QIC2191V29O1qXa49X+RDoZFh9njd7v7cseIZir1lRT2ODirkr gZPUTNf+TY9Tz79asSf4YcBgmpnpEan0k9chMNibMVdkTkYhuzjFhrJOXOxeDIadp953 Pp5HRC46JcwZ0nen1DD4WQKtT1lqlSIy1Mw9XfW+UtYwQTQ0a6zj0VG/KOjTCiUPOT0I HgSKdRlcETBTR541adTa71bgsAQrB0TtmVG/0sR3/QfYrCEjL42ao1JfTJ8nZoE8HOXi vnB77TibhXbLh6O5kOf+qtVas9H+mE7AYAxqsoVgNsrlGKlmxxR+ST0vU7xwmUFgN4MG LLtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iqSWCp6f; spf=pass (google.com: domain of gcc-patches-return-468618-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-468618-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 t3si2031929pgf.710.2017.12.06.07.28.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 07:28:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-468618-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=iqSWCp6f; spf=pass (google.com: domain of gcc-patches-return-468618-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-468618-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:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=c8EY4uK6j9fxRwLI oBTIVI93ao9dtbjn+Vqv4f98Gb1c1mNud/KT9z/Qyg+B94AaRxxohWJRyGQWydTq G0hbBsfhHuXxU0bQl82tUfcc9oK4hEOdLqTRQcr9ae+idVO/N8Rm3OwrQliU6QGR /n81HHSExjh0G6oXN0cBG/0b8xw= 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:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=8FDuwQUnVNuxBYggS4/WKf iCWcM=; b=iqSWCp6f4yuAo35s6fPKDVoquDSUM6dt019DwuqWr7XEIwaX8FIZfz 3JmQJOHW03+YTO2I681Egh1q35j93dFJXDo0NkR30qNuD3Fcb0sXdcAMR5UY55Je eGxBw+V7mw4vDRnvqunEQhNYLRNVoX6sQlxVGUznTIVrbXSqy1mj8= Received: (qmail 30595 invoked by alias); 6 Dec 2017 15:28:13 -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 30583 invoked by uid 89); 6 Dec 2017 15:28:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Possible X-HELO: mail-wr0-f178.google.com Received: from mail-wr0-f178.google.com (HELO mail-wr0-f178.google.com) (209.85.128.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Dec 2017 15:28:09 +0000 Received: by mail-wr0-f178.google.com with SMTP id s66so4321470wrc.9 for ; Wed, 06 Dec 2017 07:28:09 -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:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version; bh=yEegNSsKhtruUnLoPxSFGfv/09TP9zhIFUc5XLF2rDI=; b=cpEev2nvGlY4lFu5AyCnD7aeDBRkfSrqmLicP/9tZNYY1WMISgvQMabwgYubOnHUp0 Gy349HLLk+e84I6f9TtjcJ90lxYWijU2gA4r3/RXeVoR050k8xMp5HQ599nMlamPhwt9 utdmrrIxJ5E7AWcv4wuEMmWGkU7u7vX+B0QDtF89R1JBUpir4bUxr82p3DQq5oLldgdq 08eZ/s8FXzhUJkPTdIZrcEjnNu88vHLWgt52P8fIklATLD2r4vdn+/OrE/o+Ynt4B13x r/RuJaO7RImmuJpItUPphJpu8eYQpsxnILmWZ1U2JBxtqZt5bskD3unm6VHH7JsLZQ0L lV7Q== X-Gm-Message-State: AKGB3mJJr/iILM4e9+oEAPSBsR+LYpdXtAI9DUu90homGI2Re9jrGno/ CkK//dd3yCXEyWDew3HS4nTW5BvlU00= X-Received: by 10.223.142.193 with SMTP id q59mr8250657wrb.262.1512574087191; Wed, 06 Dec 2017 07:28:07 -0800 (PST) Received: from localhost (188.29.165.206.threembb.co.uk. [188.29.165.206]) by smtp.gmail.com with ESMTPSA id f69sm3296379wmi.46.2017.12.06.07.28.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Dec 2017 07:28:06 -0800 (PST) From: Richard Sandiford To: Richard Biener Mail-Followup-To: Richard Biener , GCC Patches , richard.sandiford@linaro.org Cc: GCC Patches Subject: Make more use of VECTOR_CST_ENCODED_ELT References: <87shcxl2ka.fsf@linaro.org> <87efohkohu.fsf@linaro.org> <87efof9a6h.fsf@linaro.org> <87fu8nao27.fsf@linaro.org> Date: Wed, 06 Dec 2017 15:28:04 +0000 In-Reply-To: <87fu8nao27.fsf@linaro.org> (Richard Sandiford's message of "Wed, 06 Dec 2017 15:11:44 +0000") Message-ID: <87mv2v98qj.fsf_-_@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch makes various bits of code operate directly on the new VECTOR_CST encoding, instead of using VECTOR_CST_ELT on all elements of the vector. Previous patches handled operations that produce a new VECTOR_CST, while this patch handles things like predicates. It also makes print_node dump the encoding instead of the full vector that the encoding represents. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also spot-checked on sparc64-linux-gnu. OK to install? Thanks, Richard 2017-12-06 Richard Sandiford gcc/ * tree-vector-builder.h (tree_vector_builder::binary_encoded_nelts): Declare. * tree-vector-builder.c (tree_vector_builder::binary_encoded_nelts): New function. * fold-const.c (negate_expr_p): Likewise. (operand_equal_p, fold_checksum_tree): Likewise. * tree-loop-distribution.c (const_with_all_bytes_same): Likewise. * tree.c (integer_zerop, integer_onep, integer_all_onesp, real_zerop) (real_onep, real_minus_onep, add_expr, initializer_zerop): Likewise. (uniform_vector_p): Likewise. * varasm.c (const_hash_1, compare_constant): Likewise. * tree-ssa-ccp.c: Include tree-vector-builder.h. (valid_lattice_transition): Operate directly on the VECTOR_CST encoding. * ipa-icf.c: Include tree-vector-builder.h. (sem_variable::equals): Operate directly on the VECTOR_CST encoding. * print-tree.c (print_node): Print encoding of VECTOR_CSTs. Index: gcc/tree-vector-builder.h =================================================================== --- gcc/tree-vector-builder.h 2017-12-06 14:49:04.289693414 +0000 +++ gcc/tree-vector-builder.h 2017-12-06 14:50:45.559564436 +0000 @@ -40,6 +40,8 @@ #define GCC_TREE_VECTOR_BUILDER_H bool new_unary_operation (tree, tree, bool); bool new_binary_operation (tree, tree, tree, bool); + static unsigned int binary_encoded_nelts (tree, tree); + private: bool equal_p (const_tree, const_tree) const; bool allow_steps_p () const; Index: gcc/tree-vector-builder.c =================================================================== --- gcc/tree-vector-builder.c 2017-12-06 14:49:04.289693414 +0000 +++ gcc/tree-vector-builder.c 2017-12-06 14:50:45.558564477 +0000 @@ -96,6 +96,24 @@ tree_vector_builder::new_binary_operatio return true; } +/* Return the number of elements that the caller needs to operate on in + order to handle a binary operation on VECTOR_CSTs T1 and T2. This static + function is used instead of new_binary_operation if the result of the + operation is not a VECTOR_CST. */ + +unsigned int +tree_vector_builder::binary_encoded_nelts (tree t1, tree t2) +{ + unsigned int nelts = TYPE_VECTOR_SUBPARTS (TREE_TYPE (t1)); + gcc_assert (nelts == TYPE_VECTOR_SUBPARTS (TREE_TYPE (t2))); + /* See new_binary_operation for details. */ + unsigned int npatterns = least_common_multiple (VECTOR_CST_NPATTERNS (t1), + VECTOR_CST_NPATTERNS (t2)); + unsigned int nelts_per_pattern = MAX (VECTOR_CST_NELTS_PER_PATTERN (t1), + VECTOR_CST_NELTS_PER_PATTERN (t2)); + return MIN (npatterns * nelts_per_pattern, nelts); +} + /* Return a vector element with the value BASE + FACTOR * STEP. */ tree Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-12-06 14:49:00.386854068 +0000 +++ gcc/fold-const.c 2017-12-06 14:50:45.557564518 +0000 @@ -410,10 +410,10 @@ negate_expr_p (tree t) if (FLOAT_TYPE_P (TREE_TYPE (type)) || TYPE_OVERFLOW_WRAPS (type)) return true; - int count = VECTOR_CST_NELTS (t), i; - - for (i = 0; i < count; i++) - if (!negate_expr_p (VECTOR_CST_ELT (t, i))) + /* Steps don't prevent negation. */ + unsigned int count = vector_cst_encoded_nelts (t); + for (unsigned int i = 0; i < count; ++i) + if (!negate_expr_p (VECTOR_CST_ENCODED_ELT (t, i))) return false; return true; @@ -2981,17 +2981,19 @@ operand_equal_p (const_tree arg0, const_ case VECTOR_CST: { - unsigned i; + if (VECTOR_CST_LOG2_NPATTERNS (arg0) + != VECTOR_CST_LOG2_NPATTERNS (arg1)) + return 0; - if (VECTOR_CST_NELTS (arg0) != VECTOR_CST_NELTS (arg1)) + if (VECTOR_CST_NELTS_PER_PATTERN (arg0) + != VECTOR_CST_NELTS_PER_PATTERN (arg1)) return 0; - for (i = 0; i < VECTOR_CST_NELTS (arg0); ++i) - { - if (!operand_equal_p (VECTOR_CST_ELT (arg0, i), - VECTOR_CST_ELT (arg1, i), flags)) - return 0; - } + unsigned int count = vector_cst_encoded_nelts (arg0); + for (unsigned int i = 0; i < count; ++i) + if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (arg0, i), + VECTOR_CST_ENCODED_ELT (arg1, i), flags)) + return 0; return 1; } @@ -11992,8 +11994,9 @@ fold_checksum_tree (const_tree expr, str fold_checksum_tree (TREE_IMAGPART (expr), ctx, ht); break; case VECTOR_CST: - for (i = 0; i < (int) VECTOR_CST_NELTS (expr); ++i) - fold_checksum_tree (VECTOR_CST_ELT (expr, i), ctx, ht); + len = vector_cst_encoded_nelts (expr); + for (i = 0; i < len; ++i) + fold_checksum_tree (VECTOR_CST_ENCODED_ELT (expr, i), ctx, ht); break; default: break; Index: gcc/tree-loop-distribution.c =================================================================== --- gcc/tree-loop-distribution.c 2017-11-29 11:06:34.810688336 +0000 +++ gcc/tree-loop-distribution.c 2017-12-06 14:50:45.558564477 +0000 @@ -944,13 +944,16 @@ const_with_all_bytes_same (tree val) return 0; break; case VECTOR_CST: - unsigned int j; - for (j = 0; j < VECTOR_CST_NELTS (val); ++j) - if (const_with_all_bytes_same (VECTOR_CST_ELT (val, j))) - break; - if (j == VECTOR_CST_NELTS (val)) - return 0; - break; + { + unsigned int count = vector_cst_encoded_nelts (val); + unsigned int j; + for (j = 0; j < count; ++j) + if (const_with_all_bytes_same (VECTOR_CST_ENCODED_ELT (val, j))) + break; + if (j == count) + return 0; + break; + } default: break; } Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-12-06 14:49:10.295445836 +0000 +++ gcc/tree.c 2017-12-06 14:50:45.560564396 +0000 @@ -2338,13 +2338,9 @@ integer_zerop (const_tree expr) return (integer_zerop (TREE_REALPART (expr)) && integer_zerop (TREE_IMAGPART (expr))); case VECTOR_CST: - { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (expr); ++i) - if (!integer_zerop (VECTOR_CST_ELT (expr, i))) - return false; - return true; - } + return (VECTOR_CST_NPATTERNS (expr) == 1 + && VECTOR_CST_DUPLICATE_P (expr) + && integer_zerop (VECTOR_CST_ENCODED_ELT (expr, 0))); default: return false; } @@ -2364,13 +2360,9 @@ integer_onep (const_tree expr) return (integer_onep (TREE_REALPART (expr)) && integer_zerop (TREE_IMAGPART (expr))); case VECTOR_CST: - { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (expr); ++i) - if (!integer_onep (VECTOR_CST_ELT (expr, i))) - return false; - return true; - } + return (VECTOR_CST_NPATTERNS (expr) == 1 + && VECTOR_CST_DUPLICATE_P (expr) + && integer_onep (VECTOR_CST_ENCODED_ELT (expr, 0))); default: return false; } @@ -2401,13 +2393,9 @@ integer_all_onesp (const_tree expr) return 1; else if (TREE_CODE (expr) == VECTOR_CST) - { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (expr); ++i) - if (!integer_all_onesp (VECTOR_CST_ELT (expr, i))) - return 0; - return 1; - } + return (VECTOR_CST_NPATTERNS (expr) == 1 + && VECTOR_CST_DUPLICATE_P (expr) + && integer_all_onesp (VECTOR_CST_ENCODED_ELT (expr, 0))); else if (TREE_CODE (expr) != INTEGER_CST) return 0; @@ -2630,9 +2618,11 @@ real_zerop (const_tree expr) && real_zerop (TREE_IMAGPART (expr)); case VECTOR_CST: { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (expr); ++i) - if (!real_zerop (VECTOR_CST_ELT (expr, i))) + /* Don't simply check for a duplicate because the predicate + accepts both +0.0 and -0.0. */ + unsigned count = vector_cst_encoded_nelts (expr); + for (unsigned int i = 0; i < count; ++i) + if (!real_zerop (VECTOR_CST_ENCODED_ELT (expr, i))) return false; return true; } @@ -2657,13 +2647,9 @@ real_onep (const_tree expr) return real_onep (TREE_REALPART (expr)) && real_zerop (TREE_IMAGPART (expr)); case VECTOR_CST: - { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (expr); ++i) - if (!real_onep (VECTOR_CST_ELT (expr, i))) - return false; - return true; - } + return (VECTOR_CST_NPATTERNS (expr) == 1 + && VECTOR_CST_DUPLICATE_P (expr) + && real_onep (VECTOR_CST_ENCODED_ELT (expr, 0))); default: return false; } @@ -2684,13 +2670,9 @@ real_minus_onep (const_tree expr) return real_minus_onep (TREE_REALPART (expr)) && real_zerop (TREE_IMAGPART (expr)); case VECTOR_CST: - { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (expr); ++i) - if (!real_minus_onep (VECTOR_CST_ELT (expr, i))) - return false; - return true; - } + return (VECTOR_CST_NPATTERNS (expr) == 1 + && VECTOR_CST_DUPLICATE_P (expr) + && real_minus_onep (VECTOR_CST_ENCODED_ELT (expr, 0))); default: return false; } @@ -7102,9 +7084,11 @@ add_expr (const_tree t, inchash::hash &h return; case VECTOR_CST: { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (t); ++i) - inchash::add_expr (VECTOR_CST_ELT (t, i), hstate, flags); + hstate.add_int (VECTOR_CST_NPATTERNS (t)); + hstate.add_int (VECTOR_CST_NELTS_PER_PATTERN (t)); + unsigned int count = vector_cst_encoded_nelts (t); + for (unsigned int i = 0; i < count; ++i) + inchash::add_expr (VECTOR_CST_ENCODED_ELT (t, i), hstate, flags); return; } case SSA_NAME: @@ -10431,13 +10415,9 @@ initializer_zerop (const_tree init) && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init)))); case VECTOR_CST: - { - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (init); ++i) - if (!initializer_zerop (VECTOR_CST_ELT (init, i))) - return false; - return true; - } + return (VECTOR_CST_NPATTERNS (init) == 1 + && VECTOR_CST_DUPLICATE_P (init) + && initializer_zerop (VECTOR_CST_ENCODED_ELT (init, 0))); case CONSTRUCTOR: { @@ -10486,12 +10466,9 @@ uniform_vector_p (const_tree vec) if (TREE_CODE (vec) == VECTOR_CST) { - first = VECTOR_CST_ELT (vec, 0); - for (i = 1; i < VECTOR_CST_NELTS (vec); ++i) - if (!operand_equal_p (first, VECTOR_CST_ELT (vec, i), 0)) - return NULL_TREE; - - return first; + if (VECTOR_CST_NPATTERNS (vec) == 1 && VECTOR_CST_DUPLICATE_P (vec)) + return VECTOR_CST_ENCODED_ELT (vec, 0); + return NULL_TREE; } else if (TREE_CODE (vec) == CONSTRUCTOR) Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2017-12-05 14:24:56.163946903 +0000 +++ gcc/varasm.c 2017-12-06 14:50:45.560564396 +0000 @@ -3007,13 +3007,11 @@ const_hash_1 (const tree exp) case VECTOR_CST: { - unsigned i; - - hi = 7 + VECTOR_CST_NELTS (exp); - - for (i = 0; i < VECTOR_CST_NELTS (exp); ++i) - hi = hi * 563 + const_hash_1 (VECTOR_CST_ELT (exp, i)); - + hi = 7 + VECTOR_CST_NPATTERNS (exp); + hi = hi * 563 + VECTOR_CST_NELTS_PER_PATTERN (exp); + unsigned int count = vector_cst_encoded_nelts (exp); + for (unsigned int i = 0; i < count; ++i) + hi = hi * 563 + const_hash_1 (VECTOR_CST_ENCODED_ELT (exp, i)); return hi; } @@ -3151,14 +3149,18 @@ compare_constant (const tree t1, const t case VECTOR_CST: { - unsigned i; + if (VECTOR_CST_NPATTERNS (t1) + != VECTOR_CST_NPATTERNS (t2)) + return 0; - if (VECTOR_CST_NELTS (t1) != VECTOR_CST_NELTS (t2)) + if (VECTOR_CST_NELTS_PER_PATTERN (t1) + != VECTOR_CST_NELTS_PER_PATTERN (t2)) return 0; - for (i = 0; i < VECTOR_CST_NELTS (t1); ++i) - if (!compare_constant (VECTOR_CST_ELT (t1, i), - VECTOR_CST_ELT (t2, i))) + unsigned int count = vector_cst_encoded_nelts (t1); + for (unsigned int i = 0; i < count; ++i) + if (!compare_constant (VECTOR_CST_ENCODED_ELT (t1, i), + VECTOR_CST_ENCODED_ELT (t2, i))) return 0; return 1; Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c 2017-12-05 14:24:55.073967105 +0000 +++ gcc/tree-ssa-ccp.c 2017-12-06 14:50:45.558564477 +0000 @@ -147,6 +147,7 @@ Free Software Foundation; either version #include "diagnostic-core.h" #include "stringpool.h" #include "attribs.h" +#include "tree-vector-builder.h" /* Possible lattice values. */ typedef enum @@ -465,11 +466,14 @@ valid_lattice_transition (ccp_prop_value else if (VECTOR_FLOAT_TYPE_P (type) && !HONOR_NANS (type)) { - for (unsigned i = 0; i < VECTOR_CST_NELTS (old_val.value); ++i) + unsigned int count + = tree_vector_builder::binary_encoded_nelts (old_val.value, + new_val.value); + for (unsigned int i = 0; i < count; ++i) if (!REAL_VALUE_ISNAN - (TREE_REAL_CST (VECTOR_CST_ELT (old_val.value, i))) - && !operand_equal_p (VECTOR_CST_ELT (old_val.value, i), - VECTOR_CST_ELT (new_val.value, i), 0)) + (TREE_REAL_CST (VECTOR_CST_ENCODED_ELT (old_val.value, i))) + && !operand_equal_p (VECTOR_CST_ENCODED_ELT (old_val.value, i), + VECTOR_CST_ENCODED_ELT (new_val.value, i), 0)) return false; return true; } Index: gcc/ipa-icf.c =================================================================== --- gcc/ipa-icf.c 2017-11-29 11:06:34.810688336 +0000 +++ gcc/ipa-icf.c 2017-12-06 14:50:45.557564518 +0000 @@ -83,6 +83,7 @@ #define INCLUDE_LIST #include "ipa-icf.h" #include "stor-layout.h" #include "dbgcnt.h" +#include "tree-vector-builder.h" using namespace ipa_icf_gimple; @@ -2024,17 +2025,17 @@ sem_variable::equals (tree t1, tree t2) &TREE_REAL_CST (t2))); case VECTOR_CST: { - unsigned i; - if (VECTOR_CST_NELTS (t1) != VECTOR_CST_NELTS (t2)) return return_false_with_msg ("VECTOR_CST nelts mismatch"); - for (i = 0; i < VECTOR_CST_NELTS (t1); ++i) - if (!sem_variable::equals (VECTOR_CST_ELT (t1, i), - VECTOR_CST_ELT (t2, i))) - return 0; + unsigned int count + = tree_vector_builder::binary_encoded_nelts (t1, t2); + for (unsigned int i = 0; i < count; ++i) + if (!sem_variable::equals (VECTOR_CST_ENCODED_ELT (t1, i), + VECTOR_CST_ENCODED_ELT (t2, i))) + return false; - return 1; + return true; } case ARRAY_REF: case ARRAY_RANGE_REF: Index: gcc/print-tree.c =================================================================== --- gcc/print-tree.c 2017-11-29 11:06:34.810688336 +0000 +++ gcc/print-tree.c 2017-12-06 14:50:45.558564477 +0000 @@ -761,24 +761,18 @@ print_node (FILE *file, const char *pref case VECTOR_CST: { - /* Big enough for 2 UINT_MAX plus the string below. */ + /* Big enough for UINT_MAX plus the string below. */ char buf[32]; - unsigned i; - for (i = 0; i < VECTOR_CST_NELTS (node); ++i) + fprintf (file, " npatterns:%u nelts-per-pattern:%u", + VECTOR_CST_NPATTERNS (node), + VECTOR_CST_NELTS_PER_PATTERN (node)); + unsigned int count = vector_cst_encoded_nelts (node); + for (unsigned int i = 0; i < count; ++i) { - unsigned j; - /* Coalesce the output of identical consecutive elements. */ - for (j = i + 1; j < VECTOR_CST_NELTS (node); j++) - if (VECTOR_CST_ELT (node, j) != VECTOR_CST_ELT (node, i)) - break; - j--; - if (i == j) - sprintf (buf, "elt:%u: ", i); - else - sprintf (buf, "elt:%u...%u: ", i, j); - print_node (file, buf, VECTOR_CST_ELT (node, i), indent + 4); - i = j; + sprintf (buf, "elt:%u: ", i); + print_node (file, buf, VECTOR_CST_ENCODED_ELT (node, i), + indent + 4); } } break;