From patchwork Mon Sep 5 12:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp160132wrt; Mon, 5 Sep 2022 05:47:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR71DbF+ycSHQgaf4Jb6rtOnKulgNUdjpAXVeJNX/MVH3PfIJ0eHf295Q7Iiw95EsbzZ8zDR X-Received: by 2002:a17:906:68ce:b0:73d:ae1a:7803 with SMTP id y14-20020a17090668ce00b0073dae1a7803mr35659898ejr.618.1662382071650; Mon, 05 Sep 2022 05:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662382071; cv=none; d=google.com; s=arc-20160816; b=Lwh+kvxziRRgIuBAmMlo88zHe5DxxD6XLgbrEZjWPcxnvWfYTJ+nEC/RncQ43HTWqh Dl+qVX3jSvPFzlLXpDWfJoePMwt7G4k/51upzRhR1HNI73Sv2B08Ji9WowUPQ1Gtg9UT TncMAHMEdTmTn9cCWcWT3NlQ+QuN/pRmY4dyvJiij+EP+TH3diBquRcDIEaJ/RnQeiCu DLBmxKJKJK8Mky8GK3JIS/f4ltcIMLq9d8idc1ZY2sLXzi0Hic4ZbkezPQkSce+162vU KTQTl/XJq3iB73CjvezI9iBR4uIFHzTlC1D9iJbk752JTsdyHt0sjPtKtw76/kJepDXG wsrg== 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:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=C4pG5Tgmez1tMThWAQRtP0XzgWXOBoJwpVZbp+GV9h4=; b=T3QbrJsezJFvZVEtikZ4f9Gs76dC3bD71VgZOvFIRF+ND9bGcbCXzRI570i986ahMa Jb60JdPZKwxRZcGwzWnmjgvFcvObU6LHuMnn878g4YBw/Evjao1HXVh9iWY7CJ2W46cN EUePrEL3PZBZ9df9l0yg8k0ZYuL+wE7qvNLxwj7DCI3Rs0GVkidWTe6frkZuflF9Pjoa xEuev+lTp81bUv8XeZsWy/r9Ql2UCh9r+Ve77RJ125rUPdriLSBcs2eG2J0rK4Jtgdx9 Btysd8pbKf743dENKyxZfTCOrpOqpHh8UWPv0vY+c4VSsKBOOV7aht4p+eqUveKVxa2i Cbjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=x3Fwvbd2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id qb24-20020a1709077e9800b0073023094027si7676786ejc.361.2022.09.05.05.47.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 05:47:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=x3Fwvbd2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 4E3C2385B805 for ; Mon, 5 Sep 2022 12:47:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E3C2385B805 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662382066; bh=C4pG5Tgmez1tMThWAQRtP0XzgWXOBoJwpVZbp+GV9h4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=x3Fwvbd2XMFBYwTCZrkFKHB0yyZ6H7ThYUEEED11wLbxpabl/iwU5LFiHcjCmRoN3 de2JSi59WKqas640mJb/CAh5nZAPYCG0yJEwPGjpoE/c0VkZT9lmtAOLhkGDRZExMR RdLVqbTGBe75Hywct3/1UKnDIFji0rG+5GzV6Bs8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 831293858CDA for ; Mon, 5 Sep 2022 12:47:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 831293858CDA Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5A8063889C for ; Mon, 5 Sep 2022 12:47:01 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4677B13A66 for ; Mon, 5 Sep 2022 12:47:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id JhvAD8XvFWM5DAAAMHmgww (envelope-from ) for ; Mon, 05 Sep 2022 12:47:01 +0000 Date: Mon, 5 Sep 2022 14:47:00 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] debug () for predicates MIME-Version: 1.0 Message-Id: <20220905124701.4677B13A66@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener 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?1743133943298982670?= X-GMAIL-MSGID: =?utf-8?q?1743133943298982670?= The following adds a debug () member to the predicate class. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. * gimple-predicate-analysis.h (predicate::debug): New. (predicate::dump): Add FILE * argument, add base overload. * gimple-predicate-analysis.cc (debug): New. (dump_pred_info): Add FILE * argument. (dump_pred_chain): Likewise. (predicate::dump): Split out preamble into overload. Add FILE * argument. (predicate::debug): New. (predicate::simplify): Adjust. (predicate::normalize): Likewise. (predicate::init_from_control_deps): Likewise. --- gcc/gimple-predicate-analysis.cc | 82 +++++++++++++++++++------------- gcc/gimple-predicate-analysis.h | 4 +- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index a754ff0a029..5629a6dc277 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -150,34 +150,34 @@ format_edge_vecs (const vec eva[], unsigned n) return str; } -/* Dump a single pred_info to DUMP_FILE. */ +/* Dump a single pred_info to F. */ static void -dump_pred_info (const pred_info &pred) +dump_pred_info (FILE *f, const pred_info &pred) { if (pred.invert) - fprintf (dump_file, "NOT ("); - print_generic_expr (dump_file, pred.pred_lhs); - fprintf (dump_file, " %s ", op_symbol_code (pred.cond_code)); - print_generic_expr (dump_file, pred.pred_rhs); + fprintf (f, "NOT ("); + print_generic_expr (f, pred.pred_lhs); + fprintf (f, " %s ", op_symbol_code (pred.cond_code)); + print_generic_expr (f, pred.pred_rhs); if (pred.invert) - fputc (')', dump_file); + fputc (')', f); } -/* Dump a pred_chain to DUMP_FILE. */ +/* Dump a pred_chain to F. */ static void -dump_pred_chain (const pred_chain &chain) +dump_pred_chain (FILE *f, const pred_chain &chain) { unsigned np = chain.length (); for (unsigned j = 0; j < np; j++) { if (j > 0) - fprintf (dump_file, " AND ("); + fprintf (f, " AND ("); else - fputc ('(', dump_file); - dump_pred_info (chain[j]); - fputc (')', dump_file); + fputc ('(', f); + dump_pred_info (f, chain[j]); + fputc (')', f); } } @@ -1405,7 +1405,7 @@ predicate::simplify (gimple *use_or_def, bool is_use) if (dump_file && dump_flags & TDF_DETAILS) { fprintf (dump_file, "Before simplication "); - dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); + dump (dump_file, use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); } unsigned n = m_preds.length (); @@ -1641,7 +1641,7 @@ predicate::normalize (gimple *use_or_def, bool is_use) if (dump_file && dump_flags & TDF_DETAILS) { fprintf (dump_file, "Before normalization "); - dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); + dump (dump_file, use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); } predicate norm_preds; @@ -1658,7 +1658,7 @@ predicate::normalize (gimple *use_or_def, bool is_use) if (dump_file) { fprintf (dump_file, "After normalization "); - dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); + dump (dump_file, use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); } } @@ -1748,7 +1748,7 @@ predicate::init_from_control_deps (const vec *dep_chains, { fprintf (dump_file, "%d -> %d: one_pred = ", e->src->index, e->dest->index); - dump_pred_info (one_pred); + dump_pred_info (dump_file, one_pred); fputc ('\n', dump_file); } @@ -1845,7 +1845,7 @@ predicate::init_from_control_deps (const vec *dep_chains, } if (DEBUG_PREDICATE_ANALYZER && dump_file) - dump (NULL, ""); + dump (dump_file); } /* Store a PRED in *THIS. */ @@ -1858,35 +1858,51 @@ predicate::push_pred (const pred_info &pred) m_preds.safe_push (chain); } -/* Dump predicates in *THIS for STMT prepended by MSG. */ +/* Dump predicates in *THIS to F. */ void -predicate::dump (gimple *stmt, const char *msg) const +predicate::dump (FILE *f) const { - fprintf (dump_file, "%s", msg); - if (stmt) - { - fputc ('\t', dump_file); - print_gimple_stmt (dump_file, stmt, 0); - fprintf (dump_file, " is conditional on:\n"); - } - unsigned np = m_preds.length (); if (np == 0) { - fprintf (dump_file, "\tTRUE (empty)\n"); + fprintf (f, "\tTRUE (empty)\n"); return; } for (unsigned i = 0; i < np; i++) { if (i > 0) - fprintf (dump_file, "\tOR ("); + fprintf (f, "\tOR ("); else - fprintf (dump_file, "\t("); - dump_pred_chain (m_preds[i]); - fprintf (dump_file, ")\n"); + fprintf (f, "\t("); + dump_pred_chain (f, m_preds[i]); + fprintf (f, ")\n"); + } +} + +/* Dump predicates in *THIS to stderr. */ + +void +predicate::debug () const +{ + dump (stderr); +} + +/* Dump predicates in *THIS for STMT prepended by MSG to F. */ + +void +predicate::dump (FILE *f, gimple *stmt, const char *msg) const +{ + fprintf (f, "%s", msg); + if (stmt) + { + fputc ('\t', f); + print_gimple_stmt (f, stmt, 0); + fprintf (f, " is conditional on:\n"); } + + dump (f); } /* Initialize USE_PREDS with the predicates of the control dependence chains diff --git a/gcc/gimple-predicate-analysis.h b/gcc/gimple-predicate-analysis.h index bc0248d7a93..972af5e0b2d 100644 --- a/gcc/gimple-predicate-analysis.h +++ b/gcc/gimple-predicate-analysis.h @@ -67,7 +67,9 @@ class predicate void init_from_control_deps (const vec *, unsigned, bool); - void dump (gimple *, const char *) const; + void dump (FILE *) const; + void dump (FILE *, gimple *, const char *) const; + void debug () const; void normalize (gimple * = NULL, bool = false); void simplify (gimple * = NULL, bool = false);