From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server28.superhosting.bg (server28.superhosting.bg [217.174.156.11]) by sourceware.org (Postfix) with ESMTPS id D61BC3858416 for ; Tue, 6 Jun 2023 04:51:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D61BC3858416 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dinux.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dinux.eu DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dinux.eu; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4EH6QltyAXz4xMP4IMZoAAOtJyLxszhYBqfBwoJ0ZwQ=; b=Bz0Cwg17ipV1FGSiKPCAfSlWgy +yU/ywjdncoSQ5mlblwJ4cak+kZDU9pqla0zbAoki+zM+GvUhpcH7PRQhcs9r3OY55uv+YEkElqn3 I+cXg/i5ty/29sIUX9I0TgEWcyZYz81M9KSIfCUjVrtGz0qdqnc4asRnBH9JT2d7jb/ssqLqdJghh SNiFS3oZglc/IKLVXZg2KyWd760en8EwEmgjRTxB9jt4f+AdaAFR/iLoNZK7xliyOAJ60/T64Lu15 8U7q1Tg2IbUrm3xHx8Ln9Vb2S1NPRlUGFZxsCyq52E1ximaSgCf1XfCeWfI63+PrZ1J58UpQc33JW QQz9oV+w==; Received: from [95.42.20.142] (port=38726 helo=kendros..) by server28.superhosting.bg with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q6OfR-0007g8-EX; Tue, 06 Jun 2023 07:51:39 +0300 From: Dimitar Dimitrov To: gcc-patches@gcc.gnu.org Cc: Dimitar Dimitrov Subject: [PATCH] riscv: Fix insn cost calculation Date: Tue, 6 Jun 2023 07:51:29 +0300 Message-Id: <20230606045130.1687824-1-dimitar@dinux.eu> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server28.superhosting.bg X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dinux.eu X-Get-Message-Sender-Via: server28.superhosting.bg: authenticated_id: dimitar@dinux.eu X-Authenticated-Sender: server28.superhosting.bg: dimitar@dinux.eu X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When building riscv32-none-elf with "--enable-checking=yes,rtl", the following ICE is observed: cc1: internal compiler error: RTL check: expected code 'const_int', have 'const_double' in riscv_const_insns, at config/riscv/riscv.cc:1313 0x843c4d rtl_check_failed_code1(rtx_def const*, rtx_code, char const*, int, char const*) /mnt/nvme/dinux/local-workspace/gcc/gcc/rtl.cc:916 0x8eab61 riscv_const_insns(rtx_def*) /mnt/nvme/dinux/local-workspace/gcc/gcc/config/riscv/riscv.cc:1313 0x15443bb riscv_legitimate_constant_p /mnt/nvme/dinux/local-workspace/gcc/gcc/config/riscv/riscv.cc:826 0xdd3c71 emit_move_insn(rtx_def*, rtx_def*) /mnt/nvme/dinux/local-workspace/gcc/gcc/expr.cc:4310 0x15f28e5 run_const_vector_selftests /mnt/nvme/dinux/local-workspace/gcc/gcc/config/riscv/riscv-selftests.cc:285 0x15f37bd selftest::riscv_run_selftests() /mnt/nvme/dinux/local-workspace/gcc/gcc/config/riscv/riscv-selftests.cc:364 0x1f6fba9 selftest::run_tests() /mnt/nvme/dinux/local-workspace/gcc/gcc/selftest-run-tests.cc:111 0x11d1f39 toplev::run_self_tests() /mnt/nvme/dinux/local-workspace/gcc/gcc/toplev.cc:2185 Fix by following the spirit of the adjacent comment, and using the dedicated riscv_const_insns() function to calculate cost for loading a constant element. Infinite recursion is not possible because the first invocation is on a CONST_VECTOR, whereas the second is on a single element of the vector (e.g. CONST_INT or CONST_DOUBLE). Regression tested for riscv32-none-elf. No changes in gcc.sum and g++.sum. I don't have setup to test riscv64. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_const_insns): Recursively call for constant element of a vector. Signed-off-by: Dimitar Dimitrov --- 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 3954c89a039..c15da1d0e30 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -1310,7 +1310,7 @@ riscv_const_insns (rtx x) a general-purpose register. This means we need as many insns as it takes to load the constant into the GPR and one vmv.v.x. */ - return 1 + riscv_integer_cost (INTVAL (elt)); + return 1 + riscv_const_insns (elt); } } -- 2.40.1