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: 109660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2623935vqr; Sun, 18 Jun 2023 13:13:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4z2+UbPhvMZiCpeUdaRJ43TjOAiegkxWqqW45cNJtPTOk2qP/gnOHLS623+UZaKuczQUgF X-Received: by 2002:a17:907:5ca:b0:97b:6c24:8d2b with SMTP id wg10-20020a17090705ca00b0097b6c248d2bmr6755358ejb.55.1687119190554; Sun, 18 Jun 2023 13:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687119190; cv=none; d=google.com; s=arc-20160816; b=jQFFnhjWlpVxC1v+ILnBTAvByDsVGSVtyF2DcSpIWjV8iMZoK55Fu12cJzmFPj2aVH IfpJ5mpjExDkaQC2qZx5JTneWVFtUmIke/OFcr6T3kjpiQbPHc4HA4LwZxHnl7I9ywQU YU79Lltoike6orrfqGxRy8jakdf4h8Qv424jTohoeLoBKB3uqY6UzReqerCU91uweIG/ RnkW1D4r9xQpV+FLnmQ/Rr4iSiHwyQkGyEaJHplc02w9Mkq8G8gYuaEcYnUDgCuapIyn r1o8fjyx/l416Cscxut4iPFOJVNE5ME8iIjOfIQNEznihRb9EuxED+H0MP5XTlkMCM2i BlwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=m9GC7eCuIKWyrQuWafpIhJfhwiSgw+mKVZcwfhsTmeU=; b=I0BwSIufJKBBtl0pZZmM2IhDnxPvcnJrZpaXHglIFUYl/pCe9LJ1WXpD4d4/L1hl85 8DgrOyTBvIfeQfSraIcbfe4SUOY1HO9d1M+YPGMzqTpuNxoqT6lLBsdDNeRwcATo4Cfw tt1yssCSJ207N1EpdcNcT1Foq7IOyp7zdImLcgsfFHwlE30+4Br7z8S0ScSdIKIDYYdr htpDbsKFnX8K5btO/zuoMNCsT/1pMCg1r9ExlxVd1sGsQqn0zrsZk1Y2UUi5kWXWt3Xq sRRFXFXS8TeVDQnpTaxaRdafPxFe4vcLomtDNwVnP2PwWJwYaLYmZpQvqmv6eVMVGo6w 1uWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uYm4Wi+M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a9-20020a1709064a4900b00965e4bf42e1si13908554ejv.351.2023.06.18.13.13.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jun 2023 13:13:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=uYm4Wi+M; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E2D53858C00 for ; Sun, 18 Jun 2023 20:13:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E2D53858C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687119189; bh=m9GC7eCuIKWyrQuWafpIhJfhwiSgw+mKVZcwfhsTmeU=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uYm4Wi+Ml+EB/0BsimUXsJC55DgIv4ljCoL0Bl50JWrrmU4CRaoqbBiTOjzcotWzs 7ZkViyQFirrf8c6tNxNoulaMWSU5FfXa+ttUbc4W+2DnT91lztVr+VXxNEKlYUo3EV /BgnGqqdsFiT5LOvvSaZoKCZxYWEgtbhPRS1WDEw= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769072692775417451?= X-GMAIL-MSGID: =?utf-8?q?1769072692775417451?= 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. */