From patchwork Wed Nov 1 21:51:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 1858100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=fMT7hoGS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SLLM51d6Mz1yQ4 for ; Thu, 2 Nov 2023 08:52:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28E5C3858C36 for ; Wed, 1 Nov 2023 21:51:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id 6F4243858D28 for ; Wed, 1 Nov 2023 21:51:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F4243858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6F4243858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698875508; cv=none; b=GcfBoyRGdaLkv3UIrgDOch4O+2t7bvVoINxdc0Kk/AdWR92kId3bOUHt/o6+Hl1FfmFXP9yrVbRtHCGfls7VPgpqe0jpA+tjYLInzJoSruhXuRsdY4sezh/vHuZUPW7gyws6aZwpBjfwa100nqfDUYQeOJvASAhmRhkHDmIz9uE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698875508; c=relaxed/simple; bh=JRYcLcFdI9ynxNAFeBiFlwG3FfzLUxUTYq7JiTXwQGo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=PB1PywGtYlMXIOBEMWljuiO6dlKqfK/wOfFpdKSc8ZpMGvaJ/pmpF437pQer1BJDsYcKLGxiLCZLv9z3OB+7alNrmB/Oulg/tD/HeKktqOObAET9iqDpFfIeadE36XZs/4YPoIg908M7HH+Kpvfl+wsvrstnDjVAHsHXfvCJA68= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1f00b95dc43so199571fac.3 for ; Wed, 01 Nov 2023 14:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1698875494; x=1699480294; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ysET4gx6WE60VNOhujkAl67QOrWNI7xHYclLsWubUP0=; b=fMT7hoGSvI448SaaqZlgBfA8E2bLJOpzr27zF5lYzSzvTtMwjBiRQJqQrSS7j2HbQa w9m/+myUj+fM32hap7sYZ9qc8XEfTOASAdoGoqEifcXx5KQkmCcm5s/2LFDGmESLhLhI m8li82iqIVBVEFJFQoHetvFkYCm77JzGuddR109QDL1FH2uJ300HESdhYIa4mrHvBcEv ksJRZY7fF3m5Wy0ZZwtS5U4SbAIJErsZxHBJhhmnWkCqTh3zlBBH3tWtNLEgqcmB3w18 0hgPWYBT61BtFxRD76C26LLLi9WSkTzY11Vbf8oJyKbzgHEJN2ww7D7Sdii6u8yvr+/o qF1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698875494; x=1699480294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ysET4gx6WE60VNOhujkAl67QOrWNI7xHYclLsWubUP0=; b=e0F0tlkbjlfvvIcn41k4RI4Rh+3fPc6phjgDXffdhpMhnFOlXtJrQicwnwL1VpHZNN e0p5nHTVeLu/iSLbZgOw5lEtI5hvHaUpKTQAZkUqR46ZwC02Hzyv8fxNBjLjyguS9gd9 QDYv9CAZrhWua9qTb0d4C+JeJUOLxn9EoMMewxuoVa4ON3qJ0fcw8vMuc1Qca/Hra6jI HAiNcbA2wNDpo9k3+VAe8+A9BeOhPksOdeROMq6A4Ubq9ZJEb6RY/GgD+/Td9c8igA1t T55LNtWL85w4QfB3QJamoDbZkwe6QpalR6CAtGXcbUbbSZVMrABdpk04X8AAWcU3CuSX QSzg== X-Gm-Message-State: AOJu0YwzhM9PaZAqZW37ZRNs/+OUyJ5EoRdM8HUjNkVJ0mvZA5uJ8Rkm od20nE0kIIety9Uwx1vbVPEoUIYcucDmL/j3akstkg== X-Google-Smtp-Source: AGHT+IEmjI0AMiaSS5KXJBOWBLVT20eXrYyHI8eHhYYv0l3Em9EK4x700R2Siz0PyTUvNnHMLj5jgg== X-Received: by 2002:a05:6870:1309:b0:1ea:7bd1:c495 with SMTP id 9-20020a056870130900b001ea7bd1c495mr16219709oab.27.1698875494526; Wed, 01 Nov 2023 14:51:34 -0700 (PDT) Received: from vineet-framework.ba.rivosinc.com (c-73-170-212-163.hsd1.ca.comcast.net. [73.170.212.163]) by smtp.gmail.com with ESMTPSA id i129-20020a639d87000000b005b96b42f7ccsm305352pgd.82.2023.11.01.14.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 14:51:34 -0700 (PDT) From: Vineet Gupta To: gcc-patches@gcc.gnu.org Cc: gnu-toolchain@rivosinc.com, Vineet Gupta , Patrick O'Neill Subject: [[Committed]] RISC-V: fix TARGET_PROMOTE_FUNCTION_MODE hook for libcalls Date: Wed, 1 Nov 2023 14:51:32 -0700 Message-Id: <20231101215132.879718-1-vineetg@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Fixes: 3496ca4e6566 ("RISC-V: Add runtime invariant support") riscv_promote_function_mode doesn't promote a SI to DI for libcalls case. It intends to do that however the code is broken (regression). The fix is what generic promote_mode () in explow.cc does. I really don't understand why the old code didn't work, but stepping thru the debugger shows old code didn't and fixed does. This showed up when testing Ajit's REE ABI extension series which probes the ABI (using a NULL tree type) and ends up hitting the libcall code path. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode returned for libcall case. Tested-by: Patrick O'Neill # pre-commit-CI #526 Signed-off-by: Vineet Gupta --- gcc/config/riscv/riscv.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 0148a4f2e431..895a098cd9a6 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -8630,9 +8630,10 @@ riscv_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, return promote_mode (type, mode, punsignedp); unsignedp = *punsignedp; - PROMOTE_MODE (as_a (mode), unsignedp, type); + scalar_mode smode = as_a (mode); + PROMOTE_MODE (smode, unsignedp, type); *punsignedp = unsignedp; - return mode; + return smode; } /* Implement TARGET_MACHINE_DEPENDENT_REORG. */