1 //===----------------------Hexagon builtin routine ------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
14 #define Q6_ALIAS(TAG) .global __qdsp_##TAG ; .set __qdsp_##TAG, __hexagon_##TAG
15 #define END(TAG) .size TAG,.-TAG
17 // Min and Max return A if B is NaN, or B if A is NaN
18 // Otherwise, they return the smaller or bigger value
20 // If values are equal, we want to favor -0.0 for min and +0.0 for max.
22 // Compares always return false for NaN
23 // if (isnan(A)) A = B; if (A > B) A = B will only trigger at most one of those options.
26 .global __hexagon_mindf3
27 .global __hexagon_maxdf3
32 .type __hexagon_mindf3,@function
33 .type __hexagon_maxdf3,@function
40 p0 = dfclass(A,#0x10) // If A is a number
41 p1 = dfcmp.gt(A,B) // AND B > A, don't swap
45 if (p0) A = B // if A is NaN use B
46 if (p1) A = B // gt is always false if either is NaN
47 p2 = dfcmp.eq(A,B) // if A == B
48 if (!p2.new) jumpr:t r31
50 // A == B, return A|B to select -0.0 over 0.0
68 if (!p2.new) jumpr:t r31
70 // A == B, return A&B to select 0.0 over -0.0