public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: fix TARGET_PROMOTE_FUNCTION_MODE hook for libcalls
@ 2023-10-31 18:35 Vineet Gupta
  2023-10-31 23:18 ` Jeff Law
  2023-11-01 19:11 ` Jeff Law
  0 siblings, 2 replies; 9+ messages in thread
From: Vineet Gupta @ 2023-10-31 18:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: gnu-toolchain, Jeff Law, Vineet Gupta

riscv_promote_function_mode doesn't promote a SI to DI for libcalls
case.

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.

[Usual caveat, I'll wait for Pre-commit CI to run the tests and report]

gcc/ChangeLog:
	* config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode
	  returned for libcall case.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
---
 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 3e27897d6d30..7b8e9af0a5af 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 <scalar_mode> (mode), unsignedp, type);
+  scalar_mode smode = as_a <scalar_mode> (mode);
+  PROMOTE_MODE (smode, unsignedp, type);
   *punsignedp = unsignedp;
-  return mode;
+  return smode;
 }
 
 /* Implement TARGET_MACHINE_DEPENDENT_REORG.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-11-01 21:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-31 18:35 [PATCH] RISC-V: fix TARGET_PROMOTE_FUNCTION_MODE hook for libcalls Vineet Gupta
2023-10-31 23:18 ` Jeff Law
2023-10-31 23:41   ` Palmer Dabbelt
2023-11-01  0:51     ` Jeff Law
2023-11-01  1:37       ` Vineet Gupta
2023-11-01 19:11 ` Jeff Law
2023-11-01 19:19   ` Vineet Gupta
2023-11-01 21:24     ` Patrick O'Neill
2023-11-01 21:51   ` [[Committed]] " Vineet Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).