From patchwork Wed Sep 26 17:22:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 975298 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-486489-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="IUhFsSwP"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WPw+VMXs"; dkim-atps=neutral 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 42L4WS4Vw0z9s55 for ; Thu, 27 Sep 2018 03:22:27 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=B2E8TsFDFalGVcElN3YNdjcXf2f08Q0sEpyxHzhGpmCkKbAslG orsMPpmgarLUyQLAXM9SNINr1anBWWndPNB7F5FX6taMWG3b7/tk7uYasZCjVESk EjO6gNu5dYYP6TqBLlc+XWBCrv6BoQ/Cj6+GtQt3+svQSzaD0QO5YDHbo= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=TjEFADlW4KVNjx5gkMscLMGXFeA=; b=IUhFsSwPv4ARYuYhPm54 DeY9IE18gNIbs3qvbgdla0tGLMchhy/dd11QoI4cFu60QWtitHh2XXW/1TYufS8K HgJqpzcwj78cyRQRZYRjgOYoKke7GDq5qT7s3BSjHes/BnSVC+XUrDOHCdcyAxEM ktVf/+6mA/cB6zD2FSNoTGg= Received: (qmail 88619 invoked by alias); 26 Sep 2018 17:22:20 -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 88603 invoked by uid 89); 26 Sep 2018 17:22:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=1s X-HELO: mail-qt1-f179.google.com Received: from mail-qt1-f179.google.com (HELO mail-qt1-f179.google.com) (209.85.160.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Sep 2018 17:22:16 +0000 Received: by mail-qt1-f179.google.com with SMTP id h22-v6so10131841qtr.13 for ; Wed, 26 Sep 2018 10:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version; bh=trjjPp+ceGPbB4qTxbQ17cBupHDnKr/p5J9TNgxiuOs=; b=WPw+VMXsTtCHqhn8DIZS4lJ6vF5vQE4gskvg16+aXfAGxhYu8Y1wR0o7fsteZCIetF 0GNYI3PjULw9KliuAR9mquZNsfoRN8BRbZ4y0vGbAEb2D1AKqcuZ1bCZYssuffSCey4J oteRMk50Y0Dz1cu6P/u0KUzLlQsC+kWXLWiY6qu5xXUsQqw6ECE8enCka4ug12r2Uv7V 4uc9xIhtcX00aRJEEs0OcIRvgDnKwfnlU6GfchvSmOGmvCsAwwedzbjTi90zmRV1hIT1 9Cg+xStyKsgPbnDzxMnuM8R7A51JmcFslNsjYRrIIPAv1tNO8yAqhbmOyeTNjBjVDE89 24DQ== Received: from localhost.localdomain (97-118-105-75.hlrn.qwest.net. [97.118.105.75]) by smtp.gmail.com with ESMTPSA id z12-v6sm1293966qtg.19.2018.09.26.10.22.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Sep 2018 10:22:13 -0700 (PDT) To: Gcc Patch List From: Martin Sebor Subject: [PATCH] change predicates to return bool instead of int Message-ID: Date: Wed, 26 Sep 2018 11:22:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-IsSubscribed: yes The attached patch modifies the return types of a number of predicates in tree.h and tree.c from int to bool. Tested on x86_64-linux with no unexpected failures. Martin gcc/ChangeLog: * tree.c (zerop): Change return type to bool. (integer_zerop, integer_onep, integer_each_onep): Same. (integer_all_onesp, integer_minus_onep, integer_pow2p): Same. (integer_nonzerop, integer_truep, tree_ctz, real_zerop): Same. (real_onep, real_minus_onep, chain_index): Same. (print_type_hash_statistics, type_list_equal): Same. * tree.h (zerop): Same. (zerop, integer_zerop, integer_onep, integer_each_onep): Same. (integer_all_onesp, integer_minus_onep, integer_pow2p): Same. (integer_nonzerop, integer_truep, tree_ctz, real_zerop): Same. (real_onep, real_minus_onep, chain_index): Same. (print_type_hash_statistics, type_list_equal): Same. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 264649) +++ gcc/tree.c (working copy) @@ -2475,7 +2475,7 @@ grow_tree_vec (tree v, int len MEM_STAT_DECL) /* Return 1 if EXPR is the constant zero, whether it is integral, float or fixed, and scalar, complex or vector. */ -int +bool zerop (const_tree expr) { return (integer_zerop (expr) @@ -2486,7 +2486,7 @@ zerop (const_tree expr) /* Return 1 if EXPR is the integer constant zero or a complex constant of zero. */ -int +bool integer_zerop (const_tree expr) { switch (TREE_CODE (expr)) @@ -2508,7 +2508,7 @@ integer_zerop (const_tree expr) /* Return 1 if EXPR is the integer constant one or the corresponding complex constant. */ -int +bool integer_onep (const_tree expr) { switch (TREE_CODE (expr)) @@ -2530,7 +2530,7 @@ integer_onep (const_tree expr) /* Return 1 if EXPR is the integer constant one. For complex and vector, return 1 if every piece is the integer constant one. */ -int +bool integer_each_onep (const_tree expr) { if (TREE_CODE (expr) == COMPLEX_CST) @@ -2543,13 +2543,13 @@ integer_each_onep (const_tree expr) /* Return 1 if EXPR is an integer containing all 1's in as much precision as it contains, or a complex or vector whose subparts are such integers. */ -int +bool integer_all_onesp (const_tree expr) { if (TREE_CODE (expr) == COMPLEX_CST && integer_all_onesp (TREE_REALPART (expr)) && integer_all_onesp (TREE_IMAGPART (expr))) - return 1; + return true; else if (TREE_CODE (expr) == VECTOR_CST) return (VECTOR_CST_NPATTERNS (expr) == 1 @@ -2557,7 +2557,7 @@ integer_all_onesp (const_tree expr) && integer_all_onesp (VECTOR_CST_ENCODED_ELT (expr, 0))); else if (TREE_CODE (expr) != INTEGER_CST) - return 0; + return false; return (wi::max_value (TYPE_PRECISION (TREE_TYPE (expr)), UNSIGNED) == wi::to_wide (expr)); @@ -2565,7 +2565,7 @@ integer_all_onesp (const_tree expr) /* Return 1 if EXPR is the integer constant minus one. */ -int +bool integer_minus_onep (const_tree expr) { if (TREE_CODE (expr) == COMPLEX_CST) @@ -2578,16 +2578,16 @@ integer_minus_onep (const_tree expr) /* Return 1 if EXPR is an integer constant that is a power of 2 (i.e., has only one bit on). */ -int +bool integer_pow2p (const_tree expr) { if (TREE_CODE (expr) == COMPLEX_CST && integer_pow2p (TREE_REALPART (expr)) && integer_zerop (TREE_IMAGPART (expr))) - return 1; + return true; if (TREE_CODE (expr) != INTEGER_CST) - return 0; + return false; return wi::popcount (wi::to_wide (expr)) == 1; } @@ -2595,7 +2595,7 @@ integer_pow2p (const_tree expr) /* Return 1 if EXPR is an integer constant other than zero or a complex constant other than zero. */ -int +bool integer_nonzerop (const_tree expr) { return ((TREE_CODE (expr) == INTEGER_CST @@ -2609,7 +2609,7 @@ integer_nonzerop (const_tree expr) return 1 if every piece is the integer constant minus one (representing the value TRUE). */ -int +bool integer_truep (const_tree expr) { if (TREE_CODE (expr) == VECTOR_CST) @@ -2619,7 +2619,7 @@ integer_truep (const_tree expr) /* Return 1 if EXPR is the fixed-point constant zero. */ -int +bool fixed_zerop (const_tree expr) { return (TREE_CODE (expr) == FIXED_CST @@ -2764,7 +2764,7 @@ tree_ctz (const_tree expr) /* Return 1 if EXPR is the real constant zero. Trailing zeroes matter for decimal float constants, so don't return 1 for them. */ -int +bool real_zerop (const_tree expr) { switch (TREE_CODE (expr)) @@ -2794,7 +2794,7 @@ real_zerop (const_tree expr) Trailing zeroes matter for decimal float constants, so don't return 1 for them. */ -int +bool real_onep (const_tree expr) { switch (TREE_CODE (expr)) @@ -2817,7 +2817,7 @@ real_onep (const_tree expr) /* Return 1 if EXPR is the real constant minus one. Trailing zeroes matter for decimal float constants, so don't return 1 for them. */ -int +bool real_minus_onep (const_tree expr) { switch (TREE_CODE (expr)) @@ -2839,7 +2839,7 @@ real_minus_onep (const_tree expr) /* Nonzero if EXP is a constant or a cast of a constant. */ -int +bool really_constant_p (const_tree exp) { /* This is not quite the same as STRIP_NOPS. It does more. */ @@ -2954,17 +2954,17 @@ chain_index (int idx, tree chain) /* Return nonzero if ELEM is part of the chain CHAIN. */ -int +bool chain_member (const_tree elem, const_tree chain) { while (chain) { if (elem == chain) - return 1; + return true; chain = DECL_CHAIN (chain); } - return 0; + return false; } /* Return the length of a chain of nodes chained through TREE_CHAIN. @@ -6712,7 +6712,7 @@ print_type_hash_statistics (void) return 1 if the lists contain the same types in the same order. Also, the TREE_PURPOSEs must match. */ -int +bool type_list_equal (const_tree l1, const_tree l2) { const_tree t1, t2; @@ -6723,7 +6723,7 @@ type_list_equal (const_tree l1, const_tree l2) && ! (1 == simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)) && (TREE_TYPE (TREE_PURPOSE (t1)) == TREE_TYPE (TREE_PURPOSE (t2)))))) - return 0; + return false; return t1 == t2; } Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 264649) +++ gcc/tree.h (working copy) @@ -4450,45 +4450,45 @@ extern vec *ctor_to_vec (tree); /* zerop (tree x) is nonzero if X is a constant of value 0. */ -extern int zerop (const_tree); +extern bool zerop (const_tree); /* integer_zerop (tree x) is nonzero if X is an integer constant of value 0. */ -extern int integer_zerop (const_tree); +extern bool integer_zerop (const_tree); /* integer_onep (tree x) is nonzero if X is an integer constant of value 1. */ -extern int integer_onep (const_tree); +extern bool integer_onep (const_tree); /* integer_onep (tree x) is nonzero if X is an integer constant of value 1, or a vector or complex where each part is 1. */ -extern int integer_each_onep (const_tree); +extern bool integer_each_onep (const_tree); /* integer_all_onesp (tree x) is nonzero if X is an integer constant all of whose significant bits are 1. */ -extern int integer_all_onesp (const_tree); +extern bool integer_all_onesp (const_tree); /* integer_minus_onep (tree x) is nonzero if X is an integer constant of value -1. */ -extern int integer_minus_onep (const_tree); +extern bool integer_minus_onep (const_tree); /* integer_pow2p (tree x) is nonzero is X is an integer constant with exactly one bit 1. */ -extern int integer_pow2p (const_tree); +extern bool integer_pow2p (const_tree); /* integer_nonzerop (tree x) is nonzero if X is an integer constant with a nonzero value. */ -extern int integer_nonzerop (const_tree); +extern bool integer_nonzerop (const_tree); /* integer_truep (tree x) is nonzero if X is an integer constant of value 1 or a vector where each element is an integer constant of value -1. */ -extern int integer_truep (const_tree); +extern bool integer_truep (const_tree); extern bool cst_and_fits_in_hwi (const_tree); extern tree num_ending_zeros (const_tree); @@ -4496,7 +4496,7 @@ extern tree num_ending_zeros (const_tree); /* fixed_zerop (tree x) is nonzero if X is a fixed-point constant of value 0. */ -extern int fixed_zerop (const_tree); +extern bool fixed_zerop (const_tree); /* staticp (tree x) is nonzero if X is a reference to data allocated at a fixed address in memory. Returns the outermost data. */ @@ -4707,8 +4707,8 @@ extern tree decl_function_context (const_tree); this _DECL with its context, or zero if none. */ extern tree decl_type_context (const_tree); -/* Return 1 if EXPR is the real constant zero. */ -extern int real_zerop (const_tree); +/* Return true if EXPR is the real constant zero. */ +extern bool real_zerop (const_tree); /* Initialize the iterator I with arguments from function FNDECL */ @@ -4889,7 +4889,7 @@ bit_field_offset (const_tree t) } extern tree strip_float_extensions (tree); -extern int really_constant_p (const_tree); +extern bool really_constant_p (const_tree); extern bool ptrdiff_tree_p (const_tree, poly_int64_pod *); extern bool decl_address_invariant_p (const_tree); extern bool decl_address_ip_invariant_p (const_tree); @@ -4920,14 +4920,14 @@ static inline hashval_t iterative_hash_expr(const_ } extern int compare_tree_int (const_tree, unsigned HOST_WIDE_INT); -extern int type_list_equal (const_tree, const_tree); -extern int chain_member (const_tree, const_tree); +extern bool type_list_equal (const_tree, const_tree); +extern bool chain_member (const_tree, const_tree); extern void dump_tree_statistics (void); extern void recompute_tree_invariant_for_addr_expr (tree); extern bool needs_to_live_in_memory (const_tree); extern tree reconstruct_complex_type (tree, tree); -extern int real_onep (const_tree); -extern int real_minus_onep (const_tree); +extern bool real_onep (const_tree); +extern bool real_minus_onep (const_tree); extern void init_ttree (void); extern void build_common_tree_nodes (bool); extern void build_common_builtin_nodes (void);