public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed 1/2] arc: Fix interrupt's epilogue.
@ 2022-07-18 12:00 Claudiu Zissulescu
  2022-07-18 12:00 ` [committed 2/2] libgcc/arc: Update udivmodsi4 and make the lib safe for rf16 Claudiu Zissulescu
  0 siblings, 1 reply; 2+ messages in thread
From: Claudiu Zissulescu @ 2022-07-18 12:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: fbedard

The stack pointer adjustment in interrupt epilogue is happening after
restoring the ZOL registers which is wrong. Fixing this.

gcc/
	* config/arc/arc.cc (arc_expand_epilogue): Adjust the frame
	pointer first when in interrupts.

gcc/testsuite/
	* gcc.target/arc/interrupt-13.c: New file.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
---
 gcc/config/arc/arc.cc                       |  2 +-
 gcc/testsuite/gcc.target/arc/interrupt-13.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/arc/interrupt-13.c

diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc
index fbc17e684a0..77730c88e55 100644
--- a/gcc/config/arc/arc.cc
+++ b/gcc/config/arc/arc.cc
@@ -3965,7 +3965,7 @@ arc_expand_epilogue (int sibcall_p)
   if (size)
     emit_insn (gen_blockage ());
 
-  if (ARC_INTERRUPT_P (fn_type) && restore_fp)
+  if (ARC_INTERRUPT_P (fn_type))
     {
       /* We need to restore FP before any SP operation in an
 	 interrupt.  */
diff --git a/gcc/testsuite/gcc.target/arc/interrupt-13.c b/gcc/testsuite/gcc.target/arc/interrupt-13.c
new file mode 100644
index 00000000000..0ed8451c512
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/interrupt-13.c
@@ -0,0 +1,15 @@
+/* { dg-options "-O2" } */
+
+extern int foo (int *);
+
+void __attribute__((interrupt("ilink")))
+irq (void)
+{
+  struct {
+    int x0;
+    int x1;
+  } a = {1 ,2};
+  foo ((int *)&a);
+}
+
+/* { dg-final { scan-assembler "add_s\\s+sp,sp,8.*pop_s\\s+r0" } } */
-- 
2.30.2


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

* [committed 2/2] libgcc/arc: Update udivmodsi4 and make the lib safe for rf16
  2022-07-18 12:00 [committed 1/2] arc: Fix interrupt's epilogue Claudiu Zissulescu
@ 2022-07-18 12:00 ` Claudiu Zissulescu
  0 siblings, 0 replies; 2+ messages in thread
From: Claudiu Zissulescu @ 2022-07-18 12:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: fbedard, Claudiu Zissulescu

From: Claudiu Zissulescu <claziss@synopsys.com>

The ARC soft udivmodsi4 algorithm and as well as using umodsi3
for reduced register set configurations are wrong.

libgcc/
	* config/arc/lib2funcs.c (udivmodsi4): Update AND mask.
	* config/arc/lib1funcs.S (umodsi3): Don't use it for RF16
	configurations.
---
 libgcc/config/arc/lib1funcs.S | 2 ++
 libgcc/config/arc/lib2funcs.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libgcc/config/arc/lib1funcs.S b/libgcc/config/arc/lib1funcs.S
index 14fd1d2f303..b06361257d1 100644
--- a/libgcc/config/arc/lib1funcs.S
+++ b/libgcc/config/arc/lib1funcs.S
@@ -936,6 +936,7 @@ SYM(__divsi3):
 
 #endif /* L_divsi3 */
 
+#ifndef __ARC_RF16__
 #ifdef  L_umodsi3
 	.section .text
 	.align 4
@@ -950,6 +951,7 @@ SYM(__umodsi3):
 	ENDFUNC(__umodsi3)
 
 #endif /* L_umodsi3 */
+#endif /* !__ARC_RF16__ */
 
 #ifdef  L_modsi3
 	.section .text
diff --git a/libgcc/config/arc/lib2funcs.c b/libgcc/config/arc/lib2funcs.c
index 70727b55365..8cba45172b2 100644
--- a/libgcc/config/arc/lib2funcs.c
+++ b/libgcc/config/arc/lib2funcs.c
@@ -59,7 +59,7 @@ udivmodsi4 (nint32_t num, nint32_t den, word_t modwanted)
   nint32_t bit = 1;
   nint32_t res = 0;
 
-  while (den < num && bit && !(den & (1LL << 63)))
+  while (den < num && bit && !(den & (1L << 31)))
     {
       den <<= 1;
       bit <<= 1;
-- 
2.30.2


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

end of thread, other threads:[~2022-07-18 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 12:00 [committed 1/2] arc: Fix interrupt's epilogue Claudiu Zissulescu
2022-07-18 12:00 ` [committed 2/2] libgcc/arc: Update udivmodsi4 and make the lib safe for rf16 Claudiu Zissulescu

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).