From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2093) id 910353858D20; Wed, 12 Jul 2023 08:12:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 910353858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689149579; bh=hAtwM1Ec8ljdfPbWTxUTUsIwi5klGSqYyZQVyUGVS9U=; h=From:To:Subject:Date:From; b=hus8oQs3eYL8YcqO5DY5Y3MVfYV98arCYobfWwbJuzLieZzhcBHojcOBaHrHZhJuc 4LoUXmZbyzgUcdBqzcfhW+Wxf/lBe2rNcs1yl+vcC8IjGuUhUCEuqTN1ZnA41HMhss 9AGLD1RIoiM22RZcpJpXtdBQ1jLfHONGFx3QuHVg= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Kito Cheng To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2452] riscv: Simplify output of MEM addresses X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Christoph_M=C3=BCllner?= X-Git-Refname: refs/heads/master X-Git-Oldrev: 208e10bf8a90f49aa40152ab7fcebe8cd7c5d31a X-Git-Newrev: b621883620b127caf20e88e59fa73e666960013e Message-Id: <20230712081259.910353858D20@sourceware.org> Date: Wed, 12 Jul 2023 08:12:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b621883620b127caf20e88e59fa73e666960013e commit r14-2452-gb621883620b127caf20e88e59fa73e666960013e Author: Christoph Müllner Date: Thu Apr 27 08:53:29 2023 +0200 riscv: Simplify output of MEM addresses We have the following situation for MEM RTX objects: * TARGET_PRINT_OPERAND expands to riscv_print_operand() * This falls into the default case (unknown or on letter) of the outer switch-case-block and the MEM case of the inner switch-case-block and calls output_address() in final.cc with XEXP (op, 0) (the address) * This calls targetm.asm_out.print_operand_address() which is riscv_print_operand_address() * riscv_print_operand_address() is targeting the address of a MEM RTX * riscv_print_operand_address() calls riscv_print_operand() for the offset and directly prints the register if the address is classified as ADDRESS_REG * This falls into the default case (unknown or on letter) of the outer switch-case-block and the default case of the inner switch-case-block and calls output_addr_const(). However, since we know that offset must be a CONST_INT (which will be followed by a '()' string), there is no need to call riscv_print_operand() for the offset. Instead we can take the shortcut and use output_addr_const(). This change also brings the code in riscv_print_operand_address() in line with the other cases, where output_addr_const() is used to print offsets. Tested with GCC regression test suite and SPEC intrate. Signed-off-by: Christoph Müllner gcc/ChangeLog: * config/riscv/riscv.cc (riscv_print_operand_address): Use output_addr_const rather than riscv_print_operand. Diff: --- gcc/config/riscv/riscv.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 38d8eb2fcf5..4d6e70b95f7 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4801,7 +4801,7 @@ riscv_print_operand_address (FILE *file, machine_mode mode ATTRIBUTE_UNUSED, rtx switch (addr.type) { case ADDRESS_REG: - riscv_print_operand (file, addr.offset, 0); + output_addr_const (file, riscv_strip_unspec_address (addr.offset)); fprintf (file, "(%s)", reg_names[REGNO (addr.reg)]); return;