This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Xtensa, committed] throw exceptions for divide-by-zero


One of Tensilica's OS engineers requested that I revise this change so that the exception handler can choose to ignore divide-by-zero and resume executing after the illegal instruction. I've committed this patch to do that.

2007-04-30 Bob Wilson <bob.wilson@acm.org>

	* config/xtensa/lib1funcs.asm (__umodsi3, __modsi3): Rearrange so that
	DIV0 exception can fall through to a normal return.

Index: config/xtensa/lib1funcs.asm
===================================================================
--- config/xtensa/lib1funcs.asm	(revision 124235)
+++ config/xtensa/lib1funcs.asm	(working copy)
@@ -654,16 +654,17 @@
 	leaf_return
 
 .Lle_one:
-	beqz	a3, .Lerror
-	movi	a2, 0
-	leaf_return
+	bnez	a3, .Lreturn0
 
-.Lerror:
 	/* Divide by zero: Use an illegal instruction to force an exception.
 	   The subsequent "DIV0" string can be recognized by the exception
 	   handler to identify the real cause of the exception.  */
 	ill
 	.ascii	"DIV0"
+
+.Lreturn0:
+	movi	a2, 0
+	leaf_return
 	.size	__umodsi3,.-__umodsi3
 
 #endif /* L_umodsi3 */
@@ -712,16 +713,17 @@
 	leaf_return
 
 .Lle_one:
-	beqz	a3, .Lerror
-	movi	a2, 0
-	leaf_return
+	bnez	a3, .Lreturn0
 
-.Lerror:
 	/* Divide by zero: Use an illegal instruction to force an exception.
 	   The subsequent "DIV0" string can be recognized by the exception
 	   handler to identify the real cause of the exception.  */
 	ill
 	.ascii	"DIV0"
+
+.Lreturn0:
+	movi	a2, 0
+	leaf_return
 	.size	__modsi3,.-__modsi3
 
 #endif /* L_modsi3 */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]