kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
/* Copyright 2009, 2010 The University of Texas at Austin.           */
kusano 2b45e8
/* All rights reserved.                                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* Redistribution and use in source and binary forms, with or        */
kusano 2b45e8
/* without modification, are permitted provided that the following   */
kusano 2b45e8
/* conditions are met:                                               */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   1. Redistributions of source code must retain the above         */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer.                                                  */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   2. Redistributions in binary form must reproduce the above      */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer in the documentation and/or other materials       */
kusano 2b45e8
/*      provided with the distribution.                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*    THIS  SOFTWARE IS PROVIDED  BY THE  UNIVERSITY OF  TEXAS AT    */
kusano 2b45e8
/*    AUSTIN  ``AS IS''  AND ANY  EXPRESS OR  IMPLIED WARRANTIES,    */
kusano 2b45e8
/*    INCLUDING, BUT  NOT LIMITED  TO, THE IMPLIED  WARRANTIES OF    */
kusano 2b45e8
/*    MERCHANTABILITY  AND FITNESS FOR  A PARTICULAR  PURPOSE ARE    */
kusano 2b45e8
/*    DISCLAIMED.  IN  NO EVENT SHALL THE UNIVERSITY  OF TEXAS AT    */
kusano 2b45e8
/*    AUSTIN OR CONTRIBUTORS BE  LIABLE FOR ANY DIRECT, INDIRECT,    */
kusano 2b45e8
/*    INCIDENTAL,  SPECIAL, EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES    */
kusano 2b45e8
/*    (INCLUDING, BUT  NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE    */
kusano 2b45e8
/*    GOODS  OR  SERVICES; LOSS  OF  USE,  DATA,  OR PROFITS;  OR    */
kusano 2b45e8
/*    BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF    */
kusano 2b45e8
/*    LIABILITY, WHETHER  IN CONTRACT, STRICT  LIABILITY, OR TORT    */
kusano 2b45e8
/*    (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT    */
kusano 2b45e8
/*    OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF ADVISED  OF  THE    */
kusano 2b45e8
/*    POSSIBILITY OF SUCH DAMAGE.                                    */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* The views and conclusions contained in the software and           */
kusano 2b45e8
/* documentation are those of the authors and should not be          */
kusano 2b45e8
/* interpreted as representing official policies, either expressed   */
kusano 2b45e8
/* or implied, of The University of Texas at Austin.                 */
kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
kusano 2b45e8
#define ASSEMBLER
kusano 2b45e8
#include "common.h"
kusano 2b45e8
kusano 2b45e8
#ifdef XDOUBLE
kusano 2b45e8
#define PREFETCH_SIZE ( 8 * 16)
kusano 2b45e8
#elif defined(DOUBLE)
kusano 2b45e8
#define PREFETCH_SIZE (16 * 16)
kusano 2b45e8
#else
kusano 2b45e8
#define PREFETCH_SIZE (32 * 16)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
#define COMPADD	0
kusano 2b45e8
#define STRIDE INCX
kusano 2b45e8
#else
kusano 2b45e8
#define COMPADD	1
kusano 2b45e8
#define STRIDE SIZE
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#define PRE1	r2
kusano 2b45e8
kusano 2b45e8
#define I	r17
kusano 2b45e8
#define J	r18
kusano 2b45e8
#define X2	r19
kusano 2b45e8
#define INCX5	r20
kusano 2b45e8
#define INCX16	r21
kusano 2b45e8
kusano 2b45e8
#define N	r32
kusano 2b45e8
#define X	r33
kusano 2b45e8
#define INCX	r34
kusano 2b45e8
#define PR	r30
kusano 2b45e8
#define ARLC	r31
kusano 2b45e8
kusano 2b45e8
kusano 2b45e8
	PROLOGUE
kusano 2b45e8
	.prologue
kusano 2b45e8
	PROFCODE
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	adds	PRE1 = PREFETCH_SIZE * SIZE, X
kusano 2b45e8
	mov	f8  = f0
kusano 2b45e8
	.save ar.lc, ARLC
kusano 2b45e8
	mov	ARLC = ar.lc
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	.body
kusano 2b45e8
#ifdef F_INTERFACE
kusano 2b45e8
	LDINT	N    = [N]
kusano 2b45e8
	LDINT	INCX = [INCX]
kusano 2b45e8
	;;
kusano 2b45e8
#ifndef USE64BITINT
kusano 2b45e8
	sxt4	N = N
kusano 2b45e8
	sxt4	INCX = INCX
kusano 2b45e8
	;;
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	cmp.ge	p6, p0 = r0, N
kusano 2b45e8
	cmp.ge	p7, p0 = r0, INCX
kusano 2b45e8
	shr	I =  N, (4 - COMPADD)
kusano 2b45e8
	}
kusano 2b45e8
	{ .mbb
kusano 2b45e8
	and	J = ((1 << (4 - COMPADD)) - 1), N
kusano 2b45e8
	(p6) 	br.ret.sptk.many b0
kusano 2b45e8
	(p7) 	br.ret.sptk.many b0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	mov	f9  = f0
kusano 2b45e8
	mov	PR = pr
kusano 2b45e8
	}
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	adds	I = -1, I
kusano 2b45e8
	mov	f10 = f0
kusano 2b45e8
	shl	INCX = INCX, (BASE_SHIFT + COMPADD)
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	shladd	X2     = INCX,  (2 - COMPADD), X
kusano 2b45e8
	mov	f11 = f0
kusano 2b45e8
	mov	pr.rot = 0
kusano 2b45e8
	}
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	shladd	INCX5  = INCX,  (2 - COMPADD), INCX
kusano 2b45e8
	mov	f12 = f0
kusano 2b45e8
	tbit.z	p0, p12 = N, (3 - COMPADD)
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	shladd	INCX16  = INCX, (4 - COMPADD), r0
kusano 2b45e8
	mov	f13 = f0
kusano 2b45e8
	mov	ar.ec= 3
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	cmp.gt	p8 ,p0  =   r0, I
kusano 2b45e8
	cmp.eq	p16, p0 = r0, r0
kusano 2b45e8
	mov	f14 = f0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
#ifdef COMPLEX
kusano 2b45e8
       adds	INCX  = - SIZE, INCX
kusano 2b45e8
       adds	INCX5 = - SIZE, INCX5
kusano 2b45e8
#else
kusano 2b45e8
	nop.m	0
kusano 2b45e8
	nop.m	0
kusano 2b45e8
#endif
kusano 2b45e8
	mov	f15 = f0
kusano 2b45e8
	}
kusano 2b45e8
	{ .mib
kusano 2b45e8
	cmp.eq	p9, p0  =   r0, J
kusano 2b45e8
	mov	ar.lc = I
kusano 2b45e8
	(p8) br.cond.dpnt  .L52
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	.align 32
kusano 2b45e8
kusano 2b45e8
.L51:
kusano 2b45e8
	(p16) LDFD	f32  = [X],  STRIDE	
kusano 2b45e8
	(p16) lfetch.nt1 [PRE1], INCX16
kusano 2b45e8
	(p18) fma.d.s1	f8  = f34, f34, f8
kusano 2b45e8
kusano 2b45e8
	(p16) LDFD	f35  = [X2], STRIDE
kusano 2b45e8
	(p18) fma.d.s1	f9  = f37, f37, f9
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	;;
kusano 2b45e8
	(p16) LDFD	f38  = [X],  INCX
kusano 2b45e8
	(p18) fma.d.s1	f10 = f40, f40, f10
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	(p16) LDFD	f41  = [X2], INCX
kusano 2b45e8
	(p18) fma.d.s1	f11 = f43, f43, f11
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	;;
kusano 2b45e8
	(p16) LDFD	f44  = [X],  STRIDE
kusano 2b45e8
	(p18) fma.d.s1	f12 = f46, f46, f12
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	(p16) LDFD	f47  = [X2], STRIDE
kusano 2b45e8
	(p18) fma.d.s1	f13 = f49, f49, f13
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	;;
kusano 2b45e8
	(p16) LDFD	f50  = [X],  INCX5
kusano 2b45e8
	(p18) fma.d.s1	f14 = f52, f52, f14
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	(p16) LDFD	f53  = [X2], INCX5
kusano 2b45e8
	(p18) fma.d.s1	f15 = f55, f55, f15
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	;;
kusano 2b45e8
	(p16) LDFD	f56  = [X],  STRIDE
kusano 2b45e8
	(p18) fma.d.s1	f8  = f58, f58, f8
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	(p16) LDFD	f59  = [X2], STRIDE
kusano 2b45e8
	(p18) fma.d.s1	f9  = f61, f61, f9
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	;;
kusano 2b45e8
	(p16) LDFD	f62  = [X],  INCX
kusano 2b45e8
	(p18) fma.d.s1	f10 = f64, f64, f10
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	(p16) LDFD	f65  = [X2], INCX
kusano 2b45e8
	(p18) fma.d.s1	f11 = f67, f67, f11
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	;;
kusano 2b45e8
	(p16) LDFD	f68  = [X],  STRIDE
kusano 2b45e8
	(p18) fma.d.s1	f12 = f70, f70, f12
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	(p16) LDFD	f71  = [X2], STRIDE	
kusano 2b45e8
	(p18) fma.d.s1	f13 = f73, f73, f13
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	;;
kusano 2b45e8
	(p16) LDFD	f74  = [X],  INCX5
kusano 2b45e8
	(p18) fma.d.s1	f14 = f76, f76, f14
kusano 2b45e8
	nop.b 0
kusano 2b45e8
	(p16) LDFD	f77  = [X2], INCX5
kusano 2b45e8
	(p18) fma.d.s1	f15 = f79, f79, f15
kusano 2b45e8
	br.ctop.sptk.few .L51
kusano 2b45e8
	;;
kusano 2b45e8
	.align 32
kusano 2b45e8
kusano 2b45e8
.L52:
kusano 2b45e8
	{ .mmb
kusano 2b45e8
	(p12) LDFD	f32  = [X],  STRIDE
kusano 2b45e8
	(p12) LDFD	f33  = [X2], STRIDE
kusano 2b45e8
	(p9) br.cond.dptk .L998
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p12) LDFD	f34  = [X],  INCX
kusano 2b45e8
	(p12) LDFD	f35  = [X2], INCX
kusano 2b45e8
	tbit.z	p0, p13 = N, (2 - COMPADD)
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p12) LDFD	f36  = [X],  STRIDE
kusano 2b45e8
	(p12) LDFD	f37  = [X2], STRIDE
kusano 2b45e8
	tbit.z	p0, p14 = N, (1 - COMPADD)
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p12) LDFD	f38  = [X],  INCX5
kusano 2b45e8
	(p12) LDFD	f39  = [X2], INCX5
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
	tbit.z	p0, p15 = N, 0
kusano 2b45e8
#endif
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	(p13) LDFD	f40  = [X], STRIDE
kusano 2b45e8
	(p12) fma.d.s1	f8  = f32, f32, f8
kusano 2b45e8
	(p12) fma.d.s1	f9  = f33, f33, f9
kusano 2b45e8
	;;
kusano 2b45e8
	(p13) LDFD	f41  = [X], INCX
kusano 2b45e8
	(p12) fma.d.s1	f10 = f34, f34, f10
kusano 2b45e8
	(p12) fma.d.s1	f11 = f35, f35, f11
kusano 2b45e8
	;;
kusano 2b45e8
	(p13) LDFD	f42  = [X], STRIDE
kusano 2b45e8
	(p12) fma.d.s1	f12 = f36, f36, f12
kusano 2b45e8
	(p12) fma.d.s1	f13 = f37, f37, f13
kusano 2b45e8
	;;
kusano 2b45e8
	(p13) LDFD	f43  = [X], INCX
kusano 2b45e8
	(p12) fma.d.s1	f14 = f38, f38, f14
kusano 2b45e8
	(p12) fma.d.s1	f15 = f39, f39, f15
kusano 2b45e8
	;;
kusano 2b45e8
	(p14) LDFD	f44  = [X], STRIDE
kusano 2b45e8
	(p13) fma.d.s1	f8  = f40, f40, f8
kusano 2b45e8
	(p13) fma.d.s1	f9  = f41, f41, f9
kusano 2b45e8
	;;
kusano 2b45e8
	(p14) LDFD	f45  = [X], INCX
kusano 2b45e8
	(p13) fma.d.s1	f10 = f42, f42, f10
kusano 2b45e8
	(p13) fma.d.s1	f11 = f43, f43, f11
kusano 2b45e8
	;;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
	(p15) LDFD	f46  = [X]
kusano 2b45e8
#endif
kusano 2b45e8
	(p14) fma.d.s1	f12 = f44, f44, f12
kusano 2b45e8
	(p14) fma.d.s1	f13 = f45, f45, f13
kusano 2b45e8
	;;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
	(p15) fma.d.s1	f14 = f46, f46, f14
kusano 2b45e8
	;;		      
kusano 2b45e8
#endif
kusano 2b45e8
	.align 32
kusano 2b45e8
kusano 2b45e8
.L998:
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	fadd.d.s1	f8  = f8,  f9
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	fadd.d.s1	f10 = f10, f11
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	fadd.d.s1	f12 = f12, f13
kusano 2b45e8
	}
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	fadd.d.s1	f14 = f14, f15
kusano 2b45e8
	mov	ar.lc = ARLC
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	fadd.d.s1	f8  = f8,  f10
kusano 2b45e8
	}
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	fadd.d.s1	f12 = f12, f14
kusano 2b45e8
	mov	pr = PR, -65474
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfb
kusano 2b45e8
	fadd.d.s1	f8  = f8,  f12
kusano 2b45e8
 	br	sqrt
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	EPILOGUE
kusano 2b45e8
kusano 2b45e8
	.section .data
kusano 2b45e8
	.type	sqrt, @function
kusano 2b45e8
	.global	sqrt