From patchwork Sun Jun 18 20:12:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1796266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=nR/H5ryE; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkkbM0JK8z20WT for ; Mon, 19 Jun 2023 06:12:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE6673858439 for ; Sun, 18 Jun 2023 20:12:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE6673858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687119164; bh=m9GC7eCuIKWyrQuWafpIhJfhwiSgw+mKVZcwfhsTmeU=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=nR/H5ryEKXYP5ImPeXbVk3C5MWsw61lw4h/iLKVBJYE5MdmlhnzjXG4V4odQNEjfh zvAdHa0sTw7gm/CuaeobPgHtpl4TOOseyoCBhjyGmops1bSxIYZWzfC2i2QYNyImJO s7XwdRVQnhI8hvSU8ssUlSCzl9ws7ztnFR7lS5nI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by sourceware.org (Postfix) with ESMTPS id 08D873858D28 for ; Sun, 18 Jun 2023 20:12:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08D873858D28 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-76240c53846so145295685a.2 for ; Sun, 18 Jun 2023 13:12:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687119143; x=1689711143; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=m9GC7eCuIKWyrQuWafpIhJfhwiSgw+mKVZcwfhsTmeU=; b=XjM71wwsy4Ka/vYFHEtKbpddtNH4D5L6jxSjODc0i2tfPmEG+ft6PhtpOrXwiP0rTM GdXD+yx/8zyVqhf6PBRqd1A8wYI82NSToL1AD+kzUVkjaEEVxyERJ1R1XOt8VS0hhidL SOsFw9oGRXS5+U8mIlqWUifaecsZKnUFOWGPY3ZEYZyUpOQ8ZpsfiIFJYjdO7DcX1Pvn YQmVW6BADSJc8ah8zUV7gWjP9u4uHvktmcIfp9e25l8SoYVEA17s3EGquxC9yvafcIvK +UzuXT7yCyWNwvccVfBJSbEXJt+GvtptzW8Ah6/NKKK1Kxg2E9XE7PWcgkv6WmMkQGhY 5K9A== X-Gm-Message-State: AC+VfDwWSzjaeYmvOIma80MkAtT3gSPuQmeHtv5/uF4RvfvBIj76hOJK rueJcAdUt0e2qNhyqIuGUYr1VnqatIO/A7vcRPTpiji9RZEF4Q== X-Google-Smtp-Source: ACHHUZ4ZvQatqgZ4EdOl2cO5Z800FscLywNE8xlOJ7y9iF0Py+fjAUSRxIcOnSjRaYIYS2zvxPfgX2vD8++p7T3u5JM= X-Received: by 2002:a05:6214:27c9:b0:62d:f515:9320 with SMTP id ge9-20020a05621427c900b0062df5159320mr9882881qvb.28.1687119142895; Sun, 18 Jun 2023 13:12:22 -0700 (PDT) MIME-Version: 1.0 Date: Sun, 18 Jun 2023 22:12:11 +0200 Message-ID: Subject: [COMMITTED] RTL: Change return type of predicate and callback functions from int to bool To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" gcc/ChangeLog: * rtl.h (*rtx_equal_p_callback_function): Change return type from int to bool. (rtx_equal_p): Ditto. (*hash_rtx_callback_function): Ditto. * rtl.cc (rtx_equal_p): Change return type from int to bool and adjust function body accordingly. * early-remat.cc (scratch_equal): Ditto. * sel-sched-ir.cc (skip_unspecs_callback): Ditto. (hash_with_unspec_callback): Ditto. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros. diff --git a/gcc/early-remat.cc b/gcc/early-remat.cc index 93cef60c790..700cb65d1e9 100644 --- a/gcc/early-remat.cc +++ b/gcc/early-remat.cc @@ -508,16 +508,16 @@ early_remat *early_remat::er; This allows us to compare two copies of a pattern, even though their SCRATCHes are always distinct. */ -static int +static bool scratch_equal (const_rtx *x, const_rtx *y, rtx *nx, rtx *ny) { if (GET_CODE (*x) == SCRATCH && GET_CODE (*y) == SCRATCH) { *nx = const0_rtx; *ny = const0_rtx; - return 1; + return true; } - return 0; + return false; } /* Hash callback functions for remat_candidate. */ diff --git a/gcc/rtl.cc b/gcc/rtl.cc index 0c004947751..635410242fa 100644 --- a/gcc/rtl.cc +++ b/gcc/rtl.cc @@ -412,13 +412,13 @@ int currently_expanding_to_rtl; -/* Return 1 if X and Y are identical-looking rtx's. +/* Return true if X and Y are identical-looking rtx's. This is the Lisp function EQUAL for rtx arguments. Call CB on each pair of rtx if CB is not NULL. When the callback returns true, we continue with the new pair. */ -int +bool rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) { int i; @@ -428,9 +428,9 @@ rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) rtx nx, ny; if (x == y) - return 1; + return true; if (x == 0 || y == 0) - return 0; + return false; /* Invoke the callback first. */ if (cb != NULL @@ -440,17 +440,17 @@ rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) code = GET_CODE (x); /* Rtx's of different codes cannot be equal. */ if (code != GET_CODE (y)) - return 0; + return false; /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent. (REG:SI x) and (REG:HI x) are NOT equivalent. */ if (GET_MODE (x) != GET_MODE (y)) - return 0; + return false; /* MEMs referring to different address space are not equivalent. */ if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y)) - return 0; + return false; /* Some RTL can be compared nonrecursively. */ switch (code) @@ -468,7 +468,7 @@ rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) case VALUE: case SCRATCH: CASE_CONST_UNIQUE: - return 0; + return false; case CONST_VECTOR: if (!same_vector_encodings_p (x, y)) @@ -500,7 +500,7 @@ rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) { case 'w': if (XWINT (x, i) != XWINT (y, i)) - return 0; + return false; break; case 'n': @@ -513,30 +513,30 @@ rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) && XINT (x, i) == XINT (y, i)) break; #endif - return 0; + return false; } break; case 'p': if (maybe_ne (SUBREG_BYTE (x), SUBREG_BYTE (y))) - return 0; + return false; break; case 'V': case 'E': /* Two vectors must have the same length. */ if (XVECLEN (x, i) != XVECLEN (y, i)) - return 0; + return false; /* And the corresponding elements must match. */ for (j = 0; j < XVECLEN (x, i); j++) - if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j), cb) == 0) - return 0; + if (!rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j), cb)) + return false; break; case 'e': - if (rtx_equal_p (XEXP (x, i), XEXP (y, i), cb) == 0) - return 0; + if (!rtx_equal_p (XEXP (x, i), XEXP (y, i), cb)) + return false; break; case 'S': @@ -544,7 +544,7 @@ rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) if ((XSTR (x, i) || XSTR (y, i)) && (! XSTR (x, i) || ! XSTR (y, i) || strcmp (XSTR (x, i), XSTR (y, i)))) - return 0; + return false; break; case 'u': @@ -562,7 +562,7 @@ rtx_equal_p (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) gcc_unreachable (); } } - return 1; + return true; } /* Return true if all elements of VEC are equal. */ diff --git a/gcc/rtl.h b/gcc/rtl.h index 3995216b58b..f66744b18e3 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3009,10 +3009,10 @@ extern rtx copy_rtx_if_shared (rtx); extern unsigned int rtx_size (const_rtx); extern rtx shallow_copy_rtx (const_rtx CXX_MEM_STAT_INFO); -typedef int (*rtx_equal_p_callback_function) (const_rtx *, const_rtx *, - rtx *, rtx *); -extern int rtx_equal_p (const_rtx, const_rtx, - rtx_equal_p_callback_function = NULL); +typedef bool (*rtx_equal_p_callback_function) (const_rtx *, const_rtx *, + rtx *, rtx *); +extern bool rtx_equal_p (const_rtx, const_rtx, + rtx_equal_p_callback_function = NULL); extern bool rtvec_all_equal_p (const_rtvec); extern bool rtvec_series_p (rtvec, int); @@ -4138,8 +4138,8 @@ extern int rtx_to_tree_code (enum rtx_code); extern int delete_trivially_dead_insns (rtx_insn *, int); extern bool exp_equiv_p (const_rtx, const_rtx, int, bool); -typedef int (*hash_rtx_callback_function) (const_rtx, machine_mode, rtx *, - machine_mode *); +typedef bool (*hash_rtx_callback_function) (const_rtx, machine_mode, rtx *, + machine_mode *); extern unsigned hash_rtx (const_rtx, machine_mode, int *, int *, bool, hash_rtx_callback_function = NULL); diff --git a/gcc/sel-sched-ir.cc b/gcc/sel-sched-ir.cc index 2c82e854b26..a829ba66331 100644 --- a/gcc/sel-sched-ir.cc +++ b/gcc/sel-sched-ir.cc @@ -1079,7 +1079,7 @@ free_nop_pool (void) /* Skip unspec to support ia64 speculation. Called from rtx_equal_p. The callback is given two rtxes XX and YY and writes the new rtxes to NX and NY in case some needs to be skipped. */ -static int +static bool skip_unspecs_callback (const_rtx *xx, const_rtx *yy, rtx *nx, rtx* ny) { const_rtx x = *xx; @@ -1091,7 +1091,7 @@ skip_unspecs_callback (const_rtx *xx, const_rtx *yy, rtx *nx, rtx* ny) { *nx = XVECEXP (x, 0, 0); *ny = CONST_CAST_RTX (y); - return 1; + return true; } if (GET_CODE (y) == UNSPEC @@ -1100,16 +1100,16 @@ skip_unspecs_callback (const_rtx *xx, const_rtx *yy, rtx *nx, rtx* ny) { *nx = CONST_CAST_RTX (x); *ny = XVECEXP (y, 0, 0); - return 1; + return true; } - return 0; + return false; } /* Callback, called from hash_rtx. Helps to hash UNSPEC rtx X in a correct way to support ia64 speculation. When changes are needed, new rtx X and new mode NMODE are written, and the callback returns true. */ -static int +static bool hash_with_unspec_callback (const_rtx x, machine_mode mode ATTRIBUTE_UNUSED, rtx *nx, machine_mode* nmode) { @@ -1119,10 +1119,10 @@ hash_with_unspec_callback (const_rtx x, machine_mode mode ATTRIBUTE_UNUSED, { *nx = XVECEXP (x, 0 ,0); *nmode = VOIDmode; - return 1; + return true; } - return 0; + return false; } /* Returns LHS and RHS are ok to be scheduled separately. */