00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2.1 of the GNU Lesser General Public License 00011 as published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU Lesser General Public 00025 License along with this program; if not, write the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00027 USA. 00028 00029 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00030 Mountain View, CA 94043, or: 00031 00032 http://www.sgi.com 00033 00034 For further information regarding this notice, see: 00035 00036 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00037 00038 */ 00039 00040 00041 /* ==================================================================== 00042 * ==================================================================== 00043 * 00044 * Module: vsqrtf.c 00045 * $Revision: 1.5 $ 00046 * $Date: 04/12/21 14:58:21-08:00 $ 00047 * $Author: bos@eng-25.internal.keyresearch.com $ 00048 * $Source: /home/bos/bk/kpro64-pending/libm/SCCS/s.vsqrtf.c $ 00049 * 00050 * Revision history: 00051 * 10-Feb-95 - Original Version 00052 * 00053 * Description: source code for vector sqrtf function 00054 * 00055 * ==================================================================== 00056 * ==================================================================== 00057 */ 00058 00059 static char *rcs_id = "$Source: /home/bos/bk/kpro64-pending/libm/SCCS/s.vsqrtf.c $ $Revision: 1.5 $"; 00060 00061 #include "libm.h" 00062 00063 #if defined(mips) && !defined(__GNUC__) 00064 extern void vfsqrt(float *, float *, long, long, long); 00065 extern void vsqrtf(float *, float *, long, long, long); 00066 00067 #pragma weak vfsqrt = __vsqrtf 00068 #pragma weak vsqrtf = __vsqrtf 00069 #endif 00070 00071 #if defined(BUILD_OS_DARWIN) /* Mach-O doesn't support aliases */ 00072 extern void __vsqrtf( float *x, float *y, long count, long stridex, 00073 long stridey ); 00074 #pragma weak vsqrtf 00075 void vsqrtf( float *x, float *y, long count, long stridex, long stridey ) { 00076 __vsqrtf(x, y, count, stridex, stridey); 00077 } 00078 #elif defined(__GNUC__) 00079 extern void __vsqrtf(float *, float *, long, long, long); 00080 void vsqrtf() __attribute__ ((weak, alias ("__vsqrtf"))); 00081 #endif 00082 00083 static const fu Inf = {0x7f800000}; 00084 00085 00086 /* ==================================================================== 00087 * 00088 * FunctionName vsqrtf 00089 * 00090 * Description computes vector sqrtf of arg 00091 * 00092 * ==================================================================== 00093 */ 00094 00095 void 00096 __vsqrtf( float *x, float *y, long count, long stridex, long stridey ) 00097 { 00098 long i; 00099 float u; 00100 float z; 00101 float result; 00102 00103 /* i = 0, 1, ..., count-1; y[i*stridey] = sqrtf(x[i*stridex]) */ 00104 00105 for ( i=0; i<count; i++ ) 00106 { 00107 #ifdef _PREFETCH 00108 #pragma prefetch_ref=*(x+8) 00109 #pragma prefetch_ref=*(y+8) 00110 #endif 00111 00112 u = z = *x; 00113 00114 #ifdef _USES_RECIP_SQRT 00115 00116 /* If _USES_RECIP_SQRT is defined, the compiler uses a reciprocal sqrt to 00117 * compute sqrt, so we have to special case zero and infinity. 00118 */ 00119 00120 if ( z == 0.0f ) 00121 u = 1.0f; 00122 00123 if ( z == Inf.f ) 00124 u = 1.0f; 00125 #endif 00126 result = sqrtf(u); 00127 00128 #ifdef _USES_RECIP_SQRT 00129 00130 if ( z == 0.0f ) 00131 result = z; 00132 00133 if ( z == Inf.f ) 00134 result = z; 00135 #endif 00136 *y = result; 00137 00138 x += stridex; 00139 y += stridey; 00140 } 00141 } 00142
1.5.6