From 9c0dba7c451ddd232dc3ba8a5ebc797762c74736 Mon Sep 17 00:00:00 2001 From: Stafford Horne Date: Sun, 21 Jul 2019 20:59:50 +0000 Subject: [PATCH] or1k: Fix issues with msoft-div Fixes bad assembly logic with software divide as reported by Richard Selvaggi. Also, add a basic test to verify the soft math works when enabled. gcc/testsuite/ChangeLog: PR target/90362 * gcc.target/or1k/div-mul-3.c: New test. libgcc/ChangeLog: PR target/90362 * config/or1k/lib1funcs.S (__udivsi3): Change l.sfeqi to l.sfeq and l.sfltsi to l.sflts equivalents as the immediate instructions are not available on every processor. Change a l.bnf to l.bf to fix logic issue. From-SVN: r273648 --- gcc/testsuite/ChangeLog | 5 +++++ libgcc/ChangeLog | 8 ++++++++ libgcc/config/or1k/lib1funcs.S | 6 +++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95e73d9fa48..846d2016740 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-22 Stafford Horne + + PR target/90362 + * gcc.target/or1k/div-mul-3.c: New test. + 2019-07-22 Stafford Horne PR target/90363 diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index d5fb54b7c3e..0a449a7dd0c 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,11 @@ +2019-07-22 Stafford Horne + + PR target/90362 + * config/or1k/lib1funcs.S (__udivsi3): Change l.sfeqi + to l.sfeq and l.sfltsi to l.sflts equivalents as the immediate + instructions are not available on every processor. Change a + l.bnf to l.bf to fix logic issue. + 2019-07-04 Iain Sandoe * config.host: Remove reference to t-darwin8. diff --git a/libgcc/config/or1k/lib1funcs.S b/libgcc/config/or1k/lib1funcs.S index d2103923486..6d058977229 100644 --- a/libgcc/config/or1k/lib1funcs.S +++ b/libgcc/config/or1k/lib1funcs.S @@ -68,18 +68,18 @@ __udivmodsi3_internal: is not clobbered by this routine, and use that as to save a return address without creating a stack frame. */ - l.sfeqi r4, 0 /* division by zero; return 0. */ + l.sfeq r4, r0 /* division by zero; return 0. */ l.ori r11, r0, 0 /* initial quotient */ l.bf 9f l.ori r12, r3, 0 /* initial remainder */ /* Given X/Y, shift Y left until Y >= X. */ l.ori r6, r0, 1 /* mask = 1 */ -1: l.sfltsi r4, 0 /* y has msb set */ +1: l.sflts r4, r0 /* y has msb set */ l.bf 2f l.sfltu r4, r12 /* y < x */ l.add r4, r4, r4 /* y <<= 1 */ - l.bnf 1b + l.bf 1b l.add r6, r6, r6 /* mask <<= 1 */ /* Shift Y back to the right again, subtracting from X. */ -- 2.30.2