From patchwork Thu Sep 22 20:07:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 673684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3sg6x90Fp4z9t17 for ; Fri, 23 Sep 2016 06:07:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=K+qrOAhR; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=E+2H4E7t7R90RoLo/k/3BofIizF+U fK21p/gMWRctrdwTHFjisTrCyEJu5Mioh84onNi9wuPQ5+tYRQHc/1CVTnoMETQI XyiCMpLRej2tPaQFTvsvpKjfrEsf+zK3qYwikqo2G/WIU4SRBX8JJENHrHl5ec/8 s7fh5aimcvNEEk= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=vPGYP2ozjf9++QrQJyNmiffJvy8=; b=K+q rOAhRWCyPJV1GY5Z5HKFTGwiVGOJjzlPONTuHa/9b3j8R9jUZiDmGpHqkcQnNFM/ H5lE3shm1Ea+haOz49NxNYR6wHVb1PHQwLeZM/ejSS31TSlwLfLK4r4+Obi2NmLU Tn2rMC1F4ucfpsSloSxkY0z3A8S+H3H/p69gzZJY= Received: (qmail 103261 invoked by alias); 22 Sep 2016 20:07:47 -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 103250 invoked by uid 89); 22 Sep 2016 20:07:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=9857, operand_equal_p, *pp, initializers X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Sep 2016 20:07:44 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A452580F7D; Thu, 22 Sep 2016 20:07:43 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-43.brq.redhat.com [10.40.204.43]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8MK7fFB015287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 22 Sep 2016 16:07:43 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u8MK7etc007508; Thu, 22 Sep 2016 22:07:40 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u8MK7dwn007507; Thu, 22 Sep 2016 22:07:39 +0200 Date: Thu, 22 Sep 2016 22:07:39 +0200 From: Jakub Jelinek To: Richard Biener , Jeff Law , Bernd Schmidt Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Use CONSTRUCTOR_NELTS macro some more Message-ID: <20160922200739.GI7282@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi! I've noticed lots of vec_safe_length (CONSTRUCTOR_ELTS (...)) uses in the sources, which IMHO are less readable than the much more often used CONSTRUCTOR_NELTS (...) macro that does the same thing. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-09-22 Jakub Jelinek * hsa-gen.c (hsa_op_immed::hsa_op_immed Use CONSTRUCTOR_NELTS (...) instead of vec_safe_length (CONSTRUCTOR_ELTS (...)). (gen_hsa_ctor_assignment): Likewise. * print-tree.c (print_node): Likewise. * tree-dump.c (dequeue_and_dump): Likewise. * tree-sra.c (sra_modify_constructor_assign): Likewise. * expr.c (store_constructor): Likewise. * fold-const.c (operand_equal_p): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * hsa-brig.c (hsa_op_immed::emit_to_buffer): Likewise. * ipa-icf-gimple.c (func_checker::compare_operand): Likewise. cp/ * typeck2.c (process_init_constructor_record): Use CONSTRUCTOR_NELTS (...) instead of vec_safe_length (CONSTRUCTOR_ELTS (...)). * decl.c (reshape_init_r): Likewise. (check_initializer): Likewise. ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Use CONSTRUCTOR_NELTS (...) instead of vec_safe_length (CONSTRUCTOR_ELTS (...)). Jakub --- gcc/hsa-gen.c.jj 2016-09-16 22:19:42.000000000 +0200 +++ gcc/hsa-gen.c 2016-09-22 17:51:23.078131950 +0200 @@ -1100,8 +1100,7 @@ hsa_op_immed::hsa_op_immed (tree tree_va /* Verify that all elements of a constructor are constants. */ if (TREE_CODE (m_tree_value) == CONSTRUCTOR) - for (unsigned i = 0; - i < vec_safe_length (CONSTRUCTOR_ELTS (m_tree_value)); i++) + for (unsigned i = 0; i < CONSTRUCTOR_NELTS (m_tree_value); i++) { tree v = CONSTRUCTOR_ELT (m_tree_value, i)->value; if (!CONSTANT_CLASS_P (v)) @@ -2845,7 +2844,7 @@ void gen_hsa_ctor_assignment (hsa_op_address *addr_lhs, tree rhs, hsa_bb *hbb, BrigAlignment8_t align) { - if (vec_safe_length (CONSTRUCTOR_ELTS (rhs))) + if (CONSTRUCTOR_NELTS (rhs)) { HSA_SORRY_AT (EXPR_LOCATION (rhs), "support for HSA does not implement load from constructor"); --- gcc/print-tree.c.jj 2016-09-21 08:54:18.000000000 +0200 +++ gcc/print-tree.c 2016-09-22 17:52:19.644409569 +0200 @@ -841,7 +841,7 @@ print_node (FILE *file, const char *pref { unsigned HOST_WIDE_INT cnt; tree index, value; - len = vec_safe_length (CONSTRUCTOR_ELTS (node)); + len = CONSTRUCTOR_NELTS (node); fprintf (file, " lngt %d", len); FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), cnt, index, value) --- gcc/tree-dump.c.jj 2016-01-04 14:55:53.000000000 +0100 +++ gcc/tree-dump.c 2016-09-22 17:52:39.430156894 +0200 @@ -646,7 +646,7 @@ dequeue_and_dump (dump_info_p di) { unsigned HOST_WIDE_INT cnt; tree index, value; - dump_int (di, "lngt", vec_safe_length (CONSTRUCTOR_ELTS (t))); + dump_int (di, "lngt", CONSTRUCTOR_NELTS (t)); FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), cnt, index, value) { dump_child ("idx", index); --- gcc/tree-sra.c.jj 2016-09-16 22:19:42.000000000 +0200 +++ gcc/tree-sra.c 2016-09-22 17:53:37.367417004 +0200 @@ -3224,7 +3224,7 @@ sra_modify_constructor_assign (gimple *s return SRA_AM_MODIFIED; } - if (vec_safe_length (CONSTRUCTOR_ELTS (gimple_assign_rhs1 (stmt))) > 0) + if (CONSTRUCTOR_NELTS (gimple_assign_rhs1 (stmt)) > 0) { /* I have never seen this code path trigger but if it can happen the following should handle it gracefully. */ --- gcc/expr.c.jj 2016-09-16 22:19:40.000000000 +0200 +++ gcc/expr.c 2016-09-22 17:49:51.441302202 +0200 @@ -6187,8 +6187,7 @@ store_constructor (tree exp, rtx target, register whose mode size isn't equal to SIZE since clear_storage can't handle this case. */ else if (size > 0 - && (((int)vec_safe_length (CONSTRUCTOR_ELTS (exp)) - != fields_length (type)) + && (((int) CONSTRUCTOR_NELTS (exp) != fields_length (type)) || mostly_zeros_p (exp)) && (!REG_P (target) || ((HOST_WIDE_INT) GET_MODE_SIZE (GET_MODE (target)) --- gcc/fold-const.c.jj 2016-09-16 22:19:38.000000000 +0200 +++ gcc/fold-const.c 2016-09-22 17:50:34.154756728 +0200 @@ -2954,8 +2954,7 @@ operand_equal_p (const_tree arg0, const_ case CONSTRUCTOR: /* In GIMPLE empty constructors are allowed in initializers of aggregates. */ - return (!vec_safe_length (CONSTRUCTOR_ELTS (arg0)) - && !vec_safe_length (CONSTRUCTOR_ELTS (arg1))); + return !CONSTRUCTOR_NELTS (arg0) && !CONSTRUCTOR_NELTS (arg1); default: break; } --- gcc/tree-pretty-print.c.jj 2016-09-16 22:19:38.000000000 +0200 +++ gcc/tree-pretty-print.c 2016-09-22 17:53:17.397672028 +0200 @@ -1983,7 +1983,7 @@ dump_generic_node (pretty_printer *pp, t dump_decl_name (pp, val, flags); else dump_generic_node (pp, val, spc, flags, false); - if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1) + if (ix != CONSTRUCTOR_NELTS (node) - 1) { pp_comma (pp); pp_space (pp); --- gcc/hsa-brig.c.jj 2016-04-22 18:21:54.000000000 +0200 +++ gcc/hsa-brig.c 2016-09-22 17:50:51.828531025 +0200 @@ -985,7 +985,7 @@ hsa_op_immed::emit_to_buffer (unsigned * } else if (TREE_CODE (m_tree_value) == CONSTRUCTOR) { - unsigned len = vec_safe_length (CONSTRUCTOR_ELTS (m_tree_value)); + unsigned len = CONSTRUCTOR_NELTS (m_tree_value); for (unsigned i = 0; i < len; i++) { tree v = CONSTRUCTOR_ELT (m_tree_value, i)->value; --- gcc/ipa-icf-gimple.c.jj 2016-04-22 18:21:29.000000000 +0200 +++ gcc/ipa-icf-gimple.c 2016-09-22 17:51:48.201811107 +0200 @@ -406,8 +406,8 @@ func_checker::compare_operand (tree t1, { case CONSTRUCTOR: { - unsigned length1 = vec_safe_length (CONSTRUCTOR_ELTS (t1)); - unsigned length2 = vec_safe_length (CONSTRUCTOR_ELTS (t2)); + unsigned length1 = CONSTRUCTOR_NELTS (t1); + unsigned length2 = CONSTRUCTOR_NELTS (t2); if (length1 != length2) return return_false (); --- gcc/cp/typeck2.c.jj 2016-07-16 10:41:04.000000000 +0200 +++ gcc/cp/typeck2.c 2016-09-22 17:56:20.391335100 +0200 @@ -1379,7 +1379,7 @@ process_init_constructor_record (tree ty if (type == error_mark_node) return PICFLAG_ERRONEOUS; - if (idx < vec_safe_length (CONSTRUCTOR_ELTS (init))) + if (idx < CONSTRUCTOR_NELTS (init)) { constructor_elt *ce = &(*CONSTRUCTOR_ELTS (init))[idx]; if (ce->index) @@ -1476,7 +1476,7 @@ process_init_constructor_record (tree ty CONSTRUCTOR_APPEND_ELT (v, field, next); } - if (idx < vec_safe_length (CONSTRUCTOR_ELTS (init))) + if (idx < CONSTRUCTOR_NELTS (init)) { if (complain & tf_error) error ("too many initializers for %qT", type); --- gcc/cp/decl.c.jj 2016-09-22 17:55:40.797840730 +0200 +++ gcc/cp/decl.c 2016-09-22 17:55:53.913673234 +0200 @@ -5948,7 +5948,7 @@ reshape_init_r (tree type, reshape_iter element (as allowed by [dcl.init.string]). */ if (!first_initializer_p && TREE_CODE (str_init) == CONSTRUCTOR - && vec_safe_length (CONSTRUCTOR_ELTS (str_init)) == 1) + && CONSTRUCTOR_NELTS (str_init) == 1) { str_init = (*CONSTRUCTOR_ELTS (str_init))[0].value; } @@ -6162,7 +6162,7 @@ check_initializer (tree decl, tree init, if (init && BRACE_ENCLOSED_INITIALIZER_P (init)) { - int init_len = vec_safe_length (CONSTRUCTOR_ELTS (init)); + int init_len = CONSTRUCTOR_NELTS (init); if (SCALAR_TYPE_P (type)) { if (init_len == 0) --- gcc/ada/gcc-interface/decl.c.jj 2016-07-14 20:28:31.000000000 +0200 +++ gcc/ada/gcc-interface/decl.c 2016-09-22 17:57:01.752806892 +0200 @@ -1339,7 +1339,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (gnu_alloc_type))); if (TREE_CODE (gnu_expr) == CONSTRUCTOR - && vec_safe_length (CONSTRUCTOR_ELTS (gnu_expr)) == 1) + && CONSTRUCTOR_NELTS (gnu_expr) == 1) gnu_expr = NULL_TREE; else gnu_expr