riscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022)
[glibc.git] / sysdeps / mips / mips64 / sub_n.S
blob99a2e61b2e8484270bb1c2c278fb3f0ca833f0d4
1 /* MIPS3 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
2  * store difference in a third limb vector.
3  *
4  * Copyright (C) 1995-2023 Free Software Foundation, Inc.
5  *
6  * This file is part of the GNU MP Library.
7  *
8  * The GNU MP Library is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or (at your
11  * option) any later version.
12  *
13  * The GNU MP Library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with the GNU MP Library.  If not, see
20  * <https://www.gnu.org/licenses/>.
21  */
23 #include <sysdep.h>
24 #include <sys/asm.h>
26 /* INPUT PARAMETERS
27  * res_ptr      $4
28  * s1_ptr       $5
29  * s2_ptr       $6
30  * size         $7
31  */
33 #ifdef __PIC__
34         .option pic2
35 #endif
36 ENTRY (__mpn_sub_n)
37 #ifdef __PIC__
38         SETUP_GP /* ??? unused */
39 #endif
40         .set    noreorder
41         .set    nomacro
43         ld      $10,0($5)
44         ld      $11,0($6)
46         daddiu  $7,$7,-1
47         and     $9,$7,4-1       # number of limbs in first loop
48         beq     $9,$0,L(L0)     # if multiple of 4 limbs, skip first loop
49         move    $2,$0
51         dsubu   $7,$7,$9
53 L(Loop0):       daddiu  $9,$9,-1
54         ld      $12,8($5)
55         daddu   $11,$11,$2
56         ld      $13,8($6)
57         sltu    $8,$11,$2
58         dsubu   $11,$10,$11
59         sltu    $2,$10,$11
60         sd      $11,0($4)
61         or      $2,$2,$8
63         daddiu  $5,$5,8
64         daddiu  $6,$6,8
65         move    $10,$12
66         move    $11,$13
67         bne     $9,$0,L(Loop0)
68         daddiu  $4,$4,8
70 L(L0):  beq     $7,$0,L(Lend)
71         nop
73 L(Loop):        daddiu  $7,$7,-4
75         ld      $12,8($5)
76         daddu   $11,$11,$2
77         ld      $13,8($6)
78         sltu    $8,$11,$2
79         dsubu   $11,$10,$11
80         sltu    $2,$10,$11
81         sd      $11,0($4)
82         or      $2,$2,$8
84         ld      $10,16($5)
85         daddu   $13,$13,$2
86         ld      $11,16($6)
87         sltu    $8,$13,$2
88         dsubu   $13,$12,$13
89         sltu    $2,$12,$13
90         sd      $13,8($4)
91         or      $2,$2,$8
93         ld      $12,24($5)
94         daddu   $11,$11,$2
95         ld      $13,24($6)
96         sltu    $8,$11,$2
97         dsubu   $11,$10,$11
98         sltu    $2,$10,$11
99         sd      $11,16($4)
100         or      $2,$2,$8
102         ld      $10,32($5)
103         daddu   $13,$13,$2
104         ld      $11,32($6)
105         sltu    $8,$13,$2
106         dsubu   $13,$12,$13
107         sltu    $2,$12,$13
108         sd      $13,24($4)
109         or      $2,$2,$8
111         daddiu  $5,$5,32
112         daddiu  $6,$6,32
114         bne     $7,$0,L(Loop)
115         daddiu  $4,$4,32
117 L(Lend):        daddu   $11,$11,$2
118         sltu    $8,$11,$2
119         dsubu   $11,$10,$11
120         sltu    $2,$10,$11
121         sd      $11,0($4)
122         j       $31
123         or      $2,$2,$8
125 END (__mpn_sub_n)