You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

min_lsx.S 5.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /***************************************************************************
  2. Copyright (c) 2023, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *****************************************************************************/
  27. #define ASSEMBLER
  28. #include "common.h"
  29. #define N $r4
  30. #define X $r5
  31. #define INCX $r6
  32. #define I $r12
  33. #define TEMP $r13
  34. #define VM0 $vr0
  35. #define VM1 $vr1
  36. #define VM2 $vr2
  37. #define VX0 $vr3
  38. #define VX1 $vr4
  39. #define VX2 $vr5
  40. #define VX3 $vr6
  41. #define t1 $r14
  42. #define t2 $r15
  43. #define t3 $r16
  44. #define t4 $r17
  45. PROLOGUE
  46. #ifdef F_INTERFACE
  47. LDINT N, 0(N)
  48. LDINT INCX, 0(INCX)
  49. #endif
  50. bge $r0, N, .L999
  51. bge $r0, INCX, .L999
  52. li.d TEMP, 1
  53. slli.d TEMP, TEMP, BASE_SHIFT
  54. slli.d INCX, INCX, BASE_SHIFT
  55. #ifdef DOUBLE
  56. vldrepl.d VM0, X, 0
  57. #else
  58. vldrepl.w VM0, X, 0
  59. #endif
  60. bne INCX, TEMP, .L20
  61. srai.d I, N, 3
  62. bge $r0, I, .L11
  63. .align 3
  64. .L10:
  65. #ifdef DOUBLE
  66. vld VX0, X, 0
  67. vld VX1, X, 16
  68. vld VX2, X, 32
  69. vld VX3, X, 48
  70. addi.d I, I, -1
  71. addi.d X, X, 64
  72. VFMIN VM1, VX0, VX1
  73. VFMIN VM2, VX2, VX3
  74. VFMIN VM0, VM0, VM1
  75. VFMIN VM0, VM0, VM2
  76. #else
  77. vld VX0, X, 0
  78. vld VX1, X, 16
  79. addi.d I, I, -1
  80. addi.d X, X, 32
  81. VFMIN VM1, VX0, VX1
  82. VFMIN VM0, VM0, VM1
  83. #endif
  84. blt $r0, I, .L10
  85. #ifdef DOUBLE
  86. vreplvei.d VX0, VM0, 0
  87. vreplvei.d VX1, VM0, 1
  88. VFMIN VM0, VX0, VX1
  89. #else
  90. vreplvei.w VX0, VM0, 0
  91. vreplvei.w VX1, VM0, 1
  92. vreplvei.w VX2, VM0, 2
  93. vreplvei.w VX3, VM0, 3
  94. VFMIN VM1, VX0, VX1
  95. VFMIN VM2, VX2, VX3
  96. VFMIN VM0, VM1, VM2
  97. #endif
  98. .align 3
  99. .L11:
  100. andi I, N, 7
  101. bge $r0, I, .L13
  102. .align 3
  103. .L12:
  104. LD $f1, X, 0
  105. addi.d I, I, -1
  106. addi.d X, X, SIZE
  107. FMIN $f0, $f0, $f1
  108. bnez I, .L12
  109. .align 3
  110. .L13:
  111. jirl $r0, $r1, 0x0
  112. .align 3
  113. .L20: // INCX!=1
  114. srai.d I, N, 3
  115. bge $r0, I, .L23
  116. .align 3
  117. .L21:
  118. #ifdef DOUBLE
  119. ld.d t1, X, 0 * SIZE
  120. add.d X, X, INCX
  121. ld.d t2, X, 0 * SIZE
  122. add.d X, X, INCX
  123. vinsgr2vr.d VX0, t1, 0
  124. vinsgr2vr.d VX0, t2, 1
  125. ld.d t3, X, 0 * SIZE
  126. add.d X, X, INCX
  127. ld.d t4, X, 0 * SIZE
  128. add.d X, X, INCX
  129. vinsgr2vr.d VX1, t3, 0
  130. vinsgr2vr.d VX1, t4, 1
  131. vfmaxa.d VM1, VX0, VX1
  132. ld.d t1, X, 0 * SIZE
  133. add.d X, X, INCX
  134. ld.d t2, X, 0 * SIZE
  135. add.d X, X, INCX
  136. vinsgr2vr.d VX0, t1, 0
  137. vinsgr2vr.d VX0, t2, 1
  138. ld.d t3, X, 0 * SIZE
  139. add.d X, X, INCX
  140. ld.d t4, X, 0 * SIZE
  141. add.d X, X, INCX
  142. vinsgr2vr.d VX1, t3, 0
  143. vinsgr2vr.d VX1, t4, 1
  144. vfmaxa.d VM2, VX0, VX1
  145. vfmaxa.d VM1, VM1, VM2
  146. vfmaxa.d VM0, VM0, VM1
  147. #else
  148. ld.w t1, X, 0
  149. add.d X, X, INCX
  150. ld.w t2, X, 0
  151. add.d X, X, INCX
  152. ld.w t3, X, 0
  153. add.d X, X, INCX
  154. ld.w t4, X, 0
  155. add.d X, X, INCX
  156. vinsgr2vr.w VX0, t1, 0
  157. vinsgr2vr.w VX0, t2, 1
  158. vinsgr2vr.w VX0, t3, 2
  159. vinsgr2vr.w VX0, t4, 3
  160. ld.w t1, X, 0
  161. add.d X, X, INCX
  162. ld.w t2, X, 0
  163. add.d X, X, INCX
  164. ld.w t3, X, 0
  165. add.d X, X, INCX
  166. ld.w t4, X, 0
  167. add.d X, X, INCX
  168. vinsgr2vr.w VX1, t1, 0
  169. vinsgr2vr.w VX1, t2, 1
  170. vinsgr2vr.w VX1, t3, 2
  171. vinsgr2vr.w VX1, t4, 3
  172. vfmaxa.s VM1, VX0, VX1
  173. vfmaxa.s VM0, VM0, VM1
  174. #endif
  175. addi.d I, I, -1
  176. blt $r0, I, .L21
  177. .align 3
  178. .L22:
  179. #ifdef DOUBLE
  180. vreplvei.d VX0, VM0, 0
  181. vreplvei.d VX1, VM0, 1
  182. VFMIN VM0, VX0, VX1
  183. #else
  184. vreplvei.w VX0, VM0, 0
  185. vreplvei.w VX1, VM0, 1
  186. vreplvei.w VX2, VM0, 2
  187. vreplvei.w VX3, VM0, 3
  188. VFMIN VM1, VX0, VX1
  189. VFMIN VM2, VX2, VX3
  190. VFMIN VM0, VM1, VM2
  191. #endif
  192. .align 3
  193. .L23: //INCX!=1 and N<8
  194. andi I, N, 7
  195. bge $r0, I, .L999
  196. .align 3
  197. .L24:
  198. LD $f1, X, 0
  199. addi.d I, I, -1
  200. add.d X, X, INCX
  201. FMIN $f0, $f0, $f1
  202. bnez I, .L24
  203. .align 3
  204. .L999:
  205. jirl $r0, $r1, 0x0
  206. EPILOGUE