From patchwork Wed Apr 14 15:10:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1466289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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@gcc.gnu.org; receiver=) Authentication-Results: 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=fJpb6Dil; 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FL5Wb1LsKz9sV5 for ; Thu, 15 Apr 2021 01:10:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 267883951829; Wed, 14 Apr 2021 15:10:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 267883951829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1618413031; bh=mrsXLe8hlnDnN1GFNYWrNPfPyC5GAf+c6pd1AKX0X3M=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fJpb6Dilmct4Zhi/Y/yLOmiMcwpQZkYpGk7XWuRPpSvntKm1wQSAcW/rx40mxHas3 YIoZuCkxvxtpc7FYYOd1dr2+3rRtVgkCqjo9s4H1XLbVa0/uf1ov7nhmRWXeBZulkM CUBDwxkIQtoZias87RA2trDITM9hGVV0Hj0IBRfw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id A6809394D8AB for ; Wed, 14 Apr 2021 15:10:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A6809394D8AB Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 37BD6113E for ; Wed, 14 Apr 2021 08:10:28 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D3F463F73B for ; Wed, 14 Apr 2021 08:10:27 -0700 (PDT) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] Better const_vector printing Date: Wed, 14 Apr 2021 16:10:26 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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 Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Looking at PR99929 showed that we weren't dumping enough information about variable-length CONST_VECTORs. Something like: (const_vector:VNx4SI [(const_int 1) (const_int 0)]) could be either: (a) 1, 0, 1, 0, repeating (b) 1 followed by all zeros This patch adds more information to the dumps. There are four cases: (a) above: (const_vector:VNx4SI repeat [ (const_int 1) (const_int 0) ]) (b) above: (const_vector:VNx4SI [ (const_int 1) repeat [ (const_int 0) ] ]) a single stepped sequence: (const_vector:VNx4SI [ (const_int 0) stepped [ (const_int 1) (const_int 2) ] ]) interleaved stepped sequences: (const_vector:VNx4SI [ (const_int 0) (const_int 40) stepped (interleave 2) [ (const_int 1) (const_int 41) (const_int 2) (const_int 42) ] ]) There are probably better syntaxes, but hopefully this is at least an improvement on the status quo. Tested on aarch64-linux-gnu, arm-linux-gnueabihf, armeb-eabi and x86_64-linux-gnu. OK to install now, or should it wait until GCC 12? (It only affects SVE in practice.) Richard gcc/ * print-rtl.c (rtx_writer::print_rtx_operand_codes_E_and_V): Print more information about variable-length CONST_VECTORs. --- gcc/print-rtl.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index c7982bce507..081fc50fab8 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -370,6 +370,10 @@ rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx) print_rtx_head, m_indent * 2, ""); m_sawclose = 0; } + if (GET_CODE (in_rtx) == CONST_VECTOR + && !GET_MODE_NUNITS (GET_MODE (in_rtx)).is_constant () + && CONST_VECTOR_DUPLICATE_P (in_rtx)) + fprintf (m_outfile, " repeat"); fputs (" [", m_outfile); if (XVEC (in_rtx, idx) != NULL) { @@ -377,12 +381,32 @@ rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx) if (XVECLEN (in_rtx, idx)) m_sawclose = 1; + int barrier = XVECLEN (in_rtx, idx); + if (GET_CODE (in_rtx) == CONST_VECTOR + && !GET_MODE_NUNITS (GET_MODE (in_rtx)).is_constant ()) + barrier = CONST_VECTOR_NPATTERNS (in_rtx); + for (int j = 0; j < XVECLEN (in_rtx, idx); j++) { int j1; + if (j == barrier) + { + fprintf (m_outfile, "\n%s%*s", + print_rtx_head, m_indent * 2, ""); + if (!CONST_VECTOR_STEPPED_P (in_rtx)) + fprintf (m_outfile, "repeat ["); + else if (CONST_VECTOR_NPATTERNS (in_rtx) == 1) + fprintf (m_outfile, "stepped ["); + else + fprintf (m_outfile, "stepped (interleave %d) [", + CONST_VECTOR_NPATTERNS (in_rtx)); + m_indent += 2; + } + print_rtx (XVECEXP (in_rtx, idx, j)); - for (j1 = j + 1; j1 < XVECLEN (in_rtx, idx); j1++) + int limit = MIN (barrier, XVECLEN (in_rtx, idx)); + for (j1 = j + 1; j1 < limit; j1++) if (XVECEXP (in_rtx, idx, j) != XVECEXP (in_rtx, idx, j1)) break; @@ -393,6 +417,12 @@ rtx_writer::print_rtx_operand_codes_E_and_V (const_rtx in_rtx, int idx) } } + if (barrier < XVECLEN (in_rtx, idx)) + { + m_indent -= 2; + fprintf (m_outfile, "\n%s%*s]", print_rtx_head, m_indent * 2, ""); + } + m_indent -= 2; } if (m_sawclose)