1.file "acoshf.s" 2 3 4// Copyright (c) 2000 - 2003, Intel Corporation 5// All rights reserved. 6// 7// 8// Redistribution and use in source and binary forms, with or without 9// modification, are permitted provided that the following conditions are 10// met: 11// 12// * Redistributions of source code must retain the above copyright 13// notice, this list of conditions and the following disclaimer. 14// 15// * Redistributions in binary form must reproduce the above copyright 16// notice, this list of conditions and the following disclaimer in the 17// documentation and/or other materials provided with the distribution. 18// 19// * The name of Intel Corporation may not be used to endorse or promote 20// products derived from this software without specific prior written 21// permission. 22 23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 27// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 31// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING 32// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34// 35// Intel Corporation is the author of this code, and requests that all 36// problem reports or change requests be submitted to it directly at 37// http://www.intel.com/software/products/opensource/libraries/num.htm. 38// 39// ============================================================== 40// History 41// ============================================================== 42// 03/28/01 Initial version 43// 04/19/01 Improved speed of the paths #1,2,3,4,5 44// 05/20/02 Cleaned up namespace and sf0 syntax 45// 02/06/03 Reordered header: .section, .global, .proc, .align 46// 05/14/03 Improved performance, set denormal flag for unorms >= 1.0 47// 48// API 49// ============================================================== 50// float acoshf(float) 51// 52// Overview of operation 53// ============================================================== 54// 55// There are 7 paths: 56// 1. x = 1.0 57// Return acoshf(x) = 0.0 58// 2. 1.0 < x < 1.000499725341796875(0x3FF0020C00000000) 59// Return acoshf(x) = sqrt(x-1) * Pol4(x), 60// where Pol4(x) = (x*C2 + C1)*(x-1) + C0 61// 62// 3. 1.000499725341796875(0x3FF0020C00000000) <= x < 2^51 63// Return acoshf(x) = log(x + sqrt(x^2 -1.0)) 64// To compute x + sqrt(x^2 -1.0) modified Newton Raphson method is used 65// (2 iterations) 66// Algorithm description for log function see below. 67// 68// 4. 2^51 <= x < +INF 69// Return acoshf(x) = log(2*x) 70// Algorithm description for log function see below. 71// 72// 5. x = +INF 73// Return acoshf(x) = +INF 74// 75// 6. x = [S,Q]NaN 76// Return acoshf(x) = QNaN 77// 78// 7. x < 1.0 79// It's domain error. Error handler with tag = 137 is called 80// 81//============================================================== 82// Algorithm Description for log(x) function 83// Below we are using the fact that inequality x - 1.0 > 2^(-6) is always 84// true for this acosh implementation 85// 86// Consider x = 2^N 1.f1 f2 f3 f4...f63 87// Log(x) = log(frcpa(x) x/frcpa(x)) 88// = log(1/frcpa(x)) + log(frcpa(x) x) 89// = -log(frcpa(x)) + log(frcpa(x) x) 90// 91// frcpa(x) = 2^-N frcpa((1.f1 f2 ... f63) 92// 93// -log(frcpa(x)) = -log(C) 94// = -log(2^-N) - log(frcpa(1.f1 f2 ... f63)) 95// 96// -log(frcpa(x)) = -log(C) 97// = +Nlog2 - log(frcpa(1.f1 f2 ... f63)) 98// 99// -log(frcpa(x)) = -log(C) 100// = +Nlog2 + log(frcpa(1.f1 f2 ... f63)) 101// 102// Log(x) = log(1/frcpa(x)) + log(frcpa(x) x) 103// 104// Log(x) = +Nlog2 + log(1./frcpa(1.f1 f2 ... f63)) + log(frcpa(x) x) 105// Log(x) = +Nlog2 - log(/frcpa(1.f1 f2 ... f63)) + log(frcpa(x) x) 106// Log(x) = +Nlog2 + T + log(frcpa(x) x) 107// 108// Log(x) = +Nlog2 + T + log(C x) 109// 110// Cx = 1 + r 111// 112// Log(x) = +Nlog2 + T + log(1+r) 113// Log(x) = +Nlog2 + T + Series( r - r^2/2 + r^3/3 - r^4/4 ....) 114// 115// 1.f1 f2 ... f8 has 256 entries. 116// They are 1 + k/2^8, k = 0 ... 255 117// These 256 values are the table entries. 118// 119// Implementation 120//============================================================== 121// C = frcpa(x) 122// r = C * x - 1 123// 124// Form rseries = r + P1*r^2 + P2*r^3 + P3*r^4 125// 126// x = f * 2*n where f is 1.f_1f_2f_3....f_63 127// Nfloat = float(n) where n is the true unbiased exponent 128// pre-index = f_1f_2....f_8 129// index = pre_index * 8 130// get the dxt table entry at index + offset = T 131// 132// result = (T + Nfloat * log(2)) + rseries 133// 134// The T table is calculated as follows 135// Form x_k = 1 + k/2^8 where k goes from 0... 255 136// y_k = frcpa(x_k) 137// log(1/y_k) in quad and round to double 138// 139 140// Registers used 141//============================================================== 142// Floating Point registers used: 143// f8, input 144// f9 -> f15, f32 -> f62 145// 146// General registers used: 147// r14 -> r27, r32 -> r39 148// 149// Predicate registers used: 150// p6 -> p15 151// 152// p6 to filter out case when x = [Q,S]NaN 153// p7,p8 to filter out case when x < 1.0 154// 155// p10 to select path #1 156// p11 to filter out case when x = +INF 157// p12 used in the frcpa 158// p13 to select path #4 159// p14,p15 to select path #2 160 161// Assembly macros 162//============================================================== 163log_GR_exp_17_ones = r14 164log_GR_signexp_f8 = r15 165log_table_address2 = r16 166log_GR_exp_16_ones = r17 167log_GR_exp_f8 = r18 168log_GR_true_exp_f8 = r19 169log_GR_significand_f8 = r20 170log_GR_index = r21 171log_GR_comp2 = r22 172acosh_GR_f8 = r23 173log_GR_comp = r24 174acosh_GR_f8_sig = r25 175log_table_address3 = r26 176NR_table_address = r27 177 178GR_SAVE_B0 = r33 179GR_SAVE_GP = r34 180GR_SAVE_PFS = r35 181 182GR_Parameter_X = r36 183GR_Parameter_Y = r37 184GR_Parameter_RESULT = r38 185acosh_GR_tag = r39 186 187//============================================================== 188log_y = f9 189NR1 = f10 190NR2 = f11 191log_y_rs = f12 192log_y_rs_iter = f13 193log_y_rs_iter1 = f14 194log_NORM_f8 = f15 195log_w = f32 196acosh_comp = f34 197acosh_comp2 = f33 198log_P3 = f35 199log_P2 = f36 200log_P1 = f37 201log2 = f38 202log_C0 = f39 203log_C1 = f40 204log_C2 = f41 205acosh_w_rs = f42 206log_C = f43 207log_arg = f44 208acosh_w_iter1 = f45 209acosh_w_iter2 = f46 210log_int_Nfloat = f47 211log_r = f48 212log_rsq = f49 213log_rp_p4 = f50 214log_rp_p32 = f51 215log_rcube = f52 216log_rp_p10 = f53 217log_rp_p2 = f54 218log_Nfloat = f55 219log_T = f56 220log_r2P_r = f57 221log_T_plus_Nlog2 = f58 222acosh_w_sqrt = f59 223acosh_w_1 = f60 224log_arg_early = f61 225log_y_rs_iter2 = f62 226 227 228// Data tables 229//============================================================== 230 231RODATA 232.align 16 233 234LOCAL_OBJECT_START(log_table_1) 235data8 0xbfd0001008f39d59 // p3 236data8 0x3fd5556073e0c45a // p2 237data8 0xbfdffffffffaea15 // p1 238data8 0x3FE62E42FEFA39EF // log2 239LOCAL_OBJECT_END(log_table_1) 240 241LOCAL_OBJECT_START(log_table_2) 242 243data8 0x3FE0000000000000 // 0.5 244data8 0x4008000000000000 // 3.0 245data8 0xD92CBAD213719F11, 0x00003FF9 // C2 3FF9D92CBAD213719F11 246data8 0x93D38EBF2EC9B073, 0x0000BFFC // C1 BFFC93D38EBF2EC9B073 247data8 0xB504F333F9DA0E32, 0x00003FFF // C0 3FFFB504F333F9DA0E32 248LOCAL_OBJECT_END(log_table_2) 249 250LOCAL_OBJECT_START(log_table_3) 251data8 0x3F60040155D5889E //log(1/frcpa(1+ 0/256) 252data8 0x3F78121214586B54 //log(1/frcpa(1+ 1/256) 253data8 0x3F841929F96832F0 //log(1/frcpa(1+ 2/256) 254data8 0x3F8C317384C75F06 //log(1/frcpa(1+ 3/256) 255data8 0x3F91A6B91AC73386 //log(1/frcpa(1+ 4/256) 256data8 0x3F95BA9A5D9AC039 //log(1/frcpa(1+ 5/256) 257data8 0x3F99D2A8074325F4 //log(1/frcpa(1+ 6/256) 258data8 0x3F9D6B2725979802 //log(1/frcpa(1+ 7/256) 259data8 0x3FA0C58FA19DFAAA //log(1/frcpa(1+ 8/256) 260data8 0x3FA2954C78CBCE1B //log(1/frcpa(1+ 9/256) 261data8 0x3FA4A94D2DA96C56 //log(1/frcpa(1+ 10/256) 262data8 0x3FA67C94F2D4BB58 //log(1/frcpa(1+ 11/256) 263data8 0x3FA85188B630F068 //log(1/frcpa(1+ 12/256) 264data8 0x3FAA6B8ABE73AF4C //log(1/frcpa(1+ 13/256) 265data8 0x3FAC441E06F72A9E //log(1/frcpa(1+ 14/256) 266data8 0x3FAE1E6713606D07 //log(1/frcpa(1+ 15/256) 267data8 0x3FAFFA6911AB9301 //log(1/frcpa(1+ 16/256) 268data8 0x3FB0EC139C5DA601 //log(1/frcpa(1+ 17/256) 269data8 0x3FB1DBD2643D190B //log(1/frcpa(1+ 18/256) 270data8 0x3FB2CC7284FE5F1C //log(1/frcpa(1+ 19/256) 271data8 0x3FB3BDF5A7D1EE64 //log(1/frcpa(1+ 20/256) 272data8 0x3FB4B05D7AA012E0 //log(1/frcpa(1+ 21/256) 273data8 0x3FB580DB7CEB5702 //log(1/frcpa(1+ 22/256) 274data8 0x3FB674F089365A7A //log(1/frcpa(1+ 23/256) 275data8 0x3FB769EF2C6B568D //log(1/frcpa(1+ 24/256) 276data8 0x3FB85FD927506A48 //log(1/frcpa(1+ 25/256) 277data8 0x3FB9335E5D594989 //log(1/frcpa(1+ 26/256) 278data8 0x3FBA2B0220C8E5F5 //log(1/frcpa(1+ 27/256) 279data8 0x3FBB0004AC1A86AC //log(1/frcpa(1+ 28/256) 280data8 0x3FBBF968769FCA11 //log(1/frcpa(1+ 29/256) 281data8 0x3FBCCFEDBFEE13A8 //log(1/frcpa(1+ 30/256) 282data8 0x3FBDA727638446A2 //log(1/frcpa(1+ 31/256) 283data8 0x3FBEA3257FE10F7A //log(1/frcpa(1+ 32/256) 284data8 0x3FBF7BE9FEDBFDE6 //log(1/frcpa(1+ 33/256) 285data8 0x3FC02AB352FF25F4 //log(1/frcpa(1+ 34/256) 286data8 0x3FC097CE579D204D //log(1/frcpa(1+ 35/256) 287data8 0x3FC1178E8227E47C //log(1/frcpa(1+ 36/256) 288data8 0x3FC185747DBECF34 //log(1/frcpa(1+ 37/256) 289data8 0x3FC1F3B925F25D41 //log(1/frcpa(1+ 38/256) 290data8 0x3FC2625D1E6DDF57 //log(1/frcpa(1+ 39/256) 291data8 0x3FC2D1610C86813A //log(1/frcpa(1+ 40/256) 292data8 0x3FC340C59741142E //log(1/frcpa(1+ 41/256) 293data8 0x3FC3B08B6757F2A9 //log(1/frcpa(1+ 42/256) 294data8 0x3FC40DFB08378003 //log(1/frcpa(1+ 43/256) 295data8 0x3FC47E74E8CA5F7C //log(1/frcpa(1+ 44/256) 296data8 0x3FC4EF51F6466DE4 //log(1/frcpa(1+ 45/256) 297data8 0x3FC56092E02BA516 //log(1/frcpa(1+ 46/256) 298data8 0x3FC5D23857CD74D5 //log(1/frcpa(1+ 47/256) 299data8 0x3FC6313A37335D76 //log(1/frcpa(1+ 48/256) 300data8 0x3FC6A399DABBD383 //log(1/frcpa(1+ 49/256) 301data8 0x3FC70337DD3CE41B //log(1/frcpa(1+ 50/256) 302data8 0x3FC77654128F6127 //log(1/frcpa(1+ 51/256) 303data8 0x3FC7E9D82A0B022D //log(1/frcpa(1+ 52/256) 304data8 0x3FC84A6B759F512F //log(1/frcpa(1+ 53/256) 305data8 0x3FC8AB47D5F5A310 //log(1/frcpa(1+ 54/256) 306data8 0x3FC91FE49096581B //log(1/frcpa(1+ 55/256) 307data8 0x3FC981634011AA75 //log(1/frcpa(1+ 56/256) 308data8 0x3FC9F6C407089664 //log(1/frcpa(1+ 57/256) 309data8 0x3FCA58E729348F43 //log(1/frcpa(1+ 58/256) 310data8 0x3FCABB55C31693AD //log(1/frcpa(1+ 59/256) 311data8 0x3FCB1E104919EFD0 //log(1/frcpa(1+ 60/256) 312data8 0x3FCB94EE93E367CB //log(1/frcpa(1+ 61/256) 313data8 0x3FCBF851C067555F //log(1/frcpa(1+ 62/256) 314data8 0x3FCC5C0254BF23A6 //log(1/frcpa(1+ 63/256) 315data8 0x3FCCC000C9DB3C52 //log(1/frcpa(1+ 64/256) 316data8 0x3FCD244D99C85674 //log(1/frcpa(1+ 65/256) 317data8 0x3FCD88E93FB2F450 //log(1/frcpa(1+ 66/256) 318data8 0x3FCDEDD437EAEF01 //log(1/frcpa(1+ 67/256) 319data8 0x3FCE530EFFE71012 //log(1/frcpa(1+ 68/256) 320data8 0x3FCEB89A1648B971 //log(1/frcpa(1+ 69/256) 321data8 0x3FCF1E75FADF9BDE //log(1/frcpa(1+ 70/256) 322data8 0x3FCF84A32EAD7C35 //log(1/frcpa(1+ 71/256) 323data8 0x3FCFEB2233EA07CD //log(1/frcpa(1+ 72/256) 324data8 0x3FD028F9C7035C1C //log(1/frcpa(1+ 73/256) 325data8 0x3FD05C8BE0D9635A //log(1/frcpa(1+ 74/256) 326data8 0x3FD085EB8F8AE797 //log(1/frcpa(1+ 75/256) 327data8 0x3FD0B9C8E32D1911 //log(1/frcpa(1+ 76/256) 328data8 0x3FD0EDD060B78081 //log(1/frcpa(1+ 77/256) 329data8 0x3FD122024CF0063F //log(1/frcpa(1+ 78/256) 330data8 0x3FD14BE2927AECD4 //log(1/frcpa(1+ 79/256) 331data8 0x3FD180618EF18ADF //log(1/frcpa(1+ 80/256) 332data8 0x3FD1B50BBE2FC63B //log(1/frcpa(1+ 81/256) 333data8 0x3FD1DF4CC7CF242D //log(1/frcpa(1+ 82/256) 334data8 0x3FD214456D0EB8D4 //log(1/frcpa(1+ 83/256) 335data8 0x3FD23EC5991EBA49 //log(1/frcpa(1+ 84/256) 336data8 0x3FD2740D9F870AFB //log(1/frcpa(1+ 85/256) 337data8 0x3FD29ECDABCDFA04 //log(1/frcpa(1+ 86/256) 338data8 0x3FD2D46602ADCCEE //log(1/frcpa(1+ 87/256) 339data8 0x3FD2FF66B04EA9D4 //log(1/frcpa(1+ 88/256) 340data8 0x3FD335504B355A37 //log(1/frcpa(1+ 89/256) 341data8 0x3FD360925EC44F5D //log(1/frcpa(1+ 90/256) 342data8 0x3FD38BF1C3337E75 //log(1/frcpa(1+ 91/256) 343data8 0x3FD3C25277333184 //log(1/frcpa(1+ 92/256) 344data8 0x3FD3EDF463C1683E //log(1/frcpa(1+ 93/256) 345data8 0x3FD419B423D5E8C7 //log(1/frcpa(1+ 94/256) 346data8 0x3FD44591E0539F49 //log(1/frcpa(1+ 95/256) 347data8 0x3FD47C9175B6F0AD //log(1/frcpa(1+ 96/256) 348data8 0x3FD4A8B341552B09 //log(1/frcpa(1+ 97/256) 349data8 0x3FD4D4F3908901A0 //log(1/frcpa(1+ 98/256) 350data8 0x3FD501528DA1F968 //log(1/frcpa(1+ 99/256) 351data8 0x3FD52DD06347D4F6 //log(1/frcpa(1+ 100/256) 352data8 0x3FD55A6D3C7B8A8A //log(1/frcpa(1+ 101/256) 353data8 0x3FD5925D2B112A59 //log(1/frcpa(1+ 102/256) 354data8 0x3FD5BF406B543DB2 //log(1/frcpa(1+ 103/256) 355data8 0x3FD5EC433D5C35AE //log(1/frcpa(1+ 104/256) 356data8 0x3FD61965CDB02C1F //log(1/frcpa(1+ 105/256) 357data8 0x3FD646A84935B2A2 //log(1/frcpa(1+ 106/256) 358data8 0x3FD6740ADD31DE94 //log(1/frcpa(1+ 107/256) 359data8 0x3FD6A18DB74A58C5 //log(1/frcpa(1+ 108/256) 360data8 0x3FD6CF31058670EC //log(1/frcpa(1+ 109/256) 361data8 0x3FD6F180E852F0BA //log(1/frcpa(1+ 110/256) 362data8 0x3FD71F5D71B894F0 //log(1/frcpa(1+ 111/256) 363data8 0x3FD74D5AEFD66D5C //log(1/frcpa(1+ 112/256) 364data8 0x3FD77B79922BD37E //log(1/frcpa(1+ 113/256) 365data8 0x3FD7A9B9889F19E2 //log(1/frcpa(1+ 114/256) 366data8 0x3FD7D81B037EB6A6 //log(1/frcpa(1+ 115/256) 367data8 0x3FD8069E33827231 //log(1/frcpa(1+ 116/256) 368data8 0x3FD82996D3EF8BCB //log(1/frcpa(1+ 117/256) 369data8 0x3FD85855776DCBFB //log(1/frcpa(1+ 118/256) 370data8 0x3FD8873658327CCF //log(1/frcpa(1+ 119/256) 371data8 0x3FD8AA75973AB8CF //log(1/frcpa(1+ 120/256) 372data8 0x3FD8D992DC8824E5 //log(1/frcpa(1+ 121/256) 373data8 0x3FD908D2EA7D9512 //log(1/frcpa(1+ 122/256) 374data8 0x3FD92C59E79C0E56 //log(1/frcpa(1+ 123/256) 375data8 0x3FD95BD750EE3ED3 //log(1/frcpa(1+ 124/256) 376data8 0x3FD98B7811A3EE5B //log(1/frcpa(1+ 125/256) 377data8 0x3FD9AF47F33D406C //log(1/frcpa(1+ 126/256) 378data8 0x3FD9DF270C1914A8 //log(1/frcpa(1+ 127/256) 379data8 0x3FDA0325ED14FDA4 //log(1/frcpa(1+ 128/256) 380data8 0x3FDA33440224FA79 //log(1/frcpa(1+ 129/256) 381data8 0x3FDA57725E80C383 //log(1/frcpa(1+ 130/256) 382data8 0x3FDA87D0165DD199 //log(1/frcpa(1+ 131/256) 383data8 0x3FDAAC2E6C03F896 //log(1/frcpa(1+ 132/256) 384data8 0x3FDADCCC6FDF6A81 //log(1/frcpa(1+ 133/256) 385data8 0x3FDB015B3EB1E790 //log(1/frcpa(1+ 134/256) 386data8 0x3FDB323A3A635948 //log(1/frcpa(1+ 135/256) 387data8 0x3FDB56FA04462909 //log(1/frcpa(1+ 136/256) 388data8 0x3FDB881AA659BC93 //log(1/frcpa(1+ 137/256) 389data8 0x3FDBAD0BEF3DB165 //log(1/frcpa(1+ 138/256) 390data8 0x3FDBD21297781C2F //log(1/frcpa(1+ 139/256) 391data8 0x3FDC039236F08819 //log(1/frcpa(1+ 140/256) 392data8 0x3FDC28CB1E4D32FD //log(1/frcpa(1+ 141/256) 393data8 0x3FDC4E19B84723C2 //log(1/frcpa(1+ 142/256) 394data8 0x3FDC7FF9C74554C9 //log(1/frcpa(1+ 143/256) 395data8 0x3FDCA57B64E9DB05 //log(1/frcpa(1+ 144/256) 396data8 0x3FDCCB130A5CEBB0 //log(1/frcpa(1+ 145/256) 397data8 0x3FDCF0C0D18F326F //log(1/frcpa(1+ 146/256) 398data8 0x3FDD232075B5A201 //log(1/frcpa(1+ 147/256) 399data8 0x3FDD490246DEFA6B //log(1/frcpa(1+ 148/256) 400data8 0x3FDD6EFA918D25CD //log(1/frcpa(1+ 149/256) 401data8 0x3FDD9509707AE52F //log(1/frcpa(1+ 150/256) 402data8 0x3FDDBB2EFE92C554 //log(1/frcpa(1+ 151/256) 403data8 0x3FDDEE2F3445E4AF //log(1/frcpa(1+ 152/256) 404data8 0x3FDE148A1A2726CE //log(1/frcpa(1+ 153/256) 405data8 0x3FDE3AFC0A49FF40 //log(1/frcpa(1+ 154/256) 406data8 0x3FDE6185206D516E //log(1/frcpa(1+ 155/256) 407data8 0x3FDE882578823D52 //log(1/frcpa(1+ 156/256) 408data8 0x3FDEAEDD2EAC990C //log(1/frcpa(1+ 157/256) 409data8 0x3FDED5AC5F436BE3 //log(1/frcpa(1+ 158/256) 410data8 0x3FDEFC9326D16AB9 //log(1/frcpa(1+ 159/256) 411data8 0x3FDF2391A2157600 //log(1/frcpa(1+ 160/256) 412data8 0x3FDF4AA7EE03192D //log(1/frcpa(1+ 161/256) 413data8 0x3FDF71D627C30BB0 //log(1/frcpa(1+ 162/256) 414data8 0x3FDF991C6CB3B379 //log(1/frcpa(1+ 163/256) 415data8 0x3FDFC07ADA69A910 //log(1/frcpa(1+ 164/256) 416data8 0x3FDFE7F18EB03D3E //log(1/frcpa(1+ 165/256) 417data8 0x3FE007C053C5002E //log(1/frcpa(1+ 166/256) 418data8 0x3FE01B942198A5A1 //log(1/frcpa(1+ 167/256) 419data8 0x3FE02F74400C64EB //log(1/frcpa(1+ 168/256) 420data8 0x3FE04360BE7603AD //log(1/frcpa(1+ 169/256) 421data8 0x3FE05759AC47FE34 //log(1/frcpa(1+ 170/256) 422data8 0x3FE06B5F1911CF52 //log(1/frcpa(1+ 171/256) 423data8 0x3FE078BF0533C568 //log(1/frcpa(1+ 172/256) 424data8 0x3FE08CD9687E7B0E //log(1/frcpa(1+ 173/256) 425data8 0x3FE0A10074CF9019 //log(1/frcpa(1+ 174/256) 426data8 0x3FE0B5343A234477 //log(1/frcpa(1+ 175/256) 427data8 0x3FE0C974C89431CE //log(1/frcpa(1+ 176/256) 428data8 0x3FE0DDC2305B9886 //log(1/frcpa(1+ 177/256) 429data8 0x3FE0EB524BAFC918 //log(1/frcpa(1+ 178/256) 430data8 0x3FE0FFB54213A476 //log(1/frcpa(1+ 179/256) 431data8 0x3FE114253DA97D9F //log(1/frcpa(1+ 180/256) 432data8 0x3FE128A24F1D9AFF //log(1/frcpa(1+ 181/256) 433data8 0x3FE1365252BF0865 //log(1/frcpa(1+ 182/256) 434data8 0x3FE14AE558B4A92D //log(1/frcpa(1+ 183/256) 435data8 0x3FE15F85A19C765B //log(1/frcpa(1+ 184/256) 436data8 0x3FE16D4D38C119FA //log(1/frcpa(1+ 185/256) 437data8 0x3FE18203C20DD133 //log(1/frcpa(1+ 186/256) 438data8 0x3FE196C7BC4B1F3B //log(1/frcpa(1+ 187/256) 439data8 0x3FE1A4A738B7A33C //log(1/frcpa(1+ 188/256) 440data8 0x3FE1B981C0C9653D //log(1/frcpa(1+ 189/256) 441data8 0x3FE1CE69E8BB106B //log(1/frcpa(1+ 190/256) 442data8 0x3FE1DC619DE06944 //log(1/frcpa(1+ 191/256) 443data8 0x3FE1F160A2AD0DA4 //log(1/frcpa(1+ 192/256) 444data8 0x3FE2066D7740737E //log(1/frcpa(1+ 193/256) 445data8 0x3FE2147DBA47A394 //log(1/frcpa(1+ 194/256) 446data8 0x3FE229A1BC5EBAC3 //log(1/frcpa(1+ 195/256) 447data8 0x3FE237C1841A502E //log(1/frcpa(1+ 196/256) 448data8 0x3FE24CFCE6F80D9A //log(1/frcpa(1+ 197/256) 449data8 0x3FE25B2C55CD5762 //log(1/frcpa(1+ 198/256) 450data8 0x3FE2707F4D5F7C41 //log(1/frcpa(1+ 199/256) 451data8 0x3FE285E0842CA384 //log(1/frcpa(1+ 200/256) 452data8 0x3FE294294708B773 //log(1/frcpa(1+ 201/256) 453data8 0x3FE2A9A2670AFF0C //log(1/frcpa(1+ 202/256) 454data8 0x3FE2B7FB2C8D1CC1 //log(1/frcpa(1+ 203/256) 455data8 0x3FE2C65A6395F5F5 //log(1/frcpa(1+ 204/256) 456data8 0x3FE2DBF557B0DF43 //log(1/frcpa(1+ 205/256) 457data8 0x3FE2EA64C3F97655 //log(1/frcpa(1+ 206/256) 458data8 0x3FE3001823684D73 //log(1/frcpa(1+ 207/256) 459data8 0x3FE30E97E9A8B5CD //log(1/frcpa(1+ 208/256) 460data8 0x3FE32463EBDD34EA //log(1/frcpa(1+ 209/256) 461data8 0x3FE332F4314AD796 //log(1/frcpa(1+ 210/256) 462data8 0x3FE348D90E7464D0 //log(1/frcpa(1+ 211/256) 463data8 0x3FE35779F8C43D6E //log(1/frcpa(1+ 212/256) 464data8 0x3FE36621961A6A99 //log(1/frcpa(1+ 213/256) 465data8 0x3FE37C299F3C366A //log(1/frcpa(1+ 214/256) 466data8 0x3FE38AE2171976E7 //log(1/frcpa(1+ 215/256) 467data8 0x3FE399A157A603E7 //log(1/frcpa(1+ 216/256) 468data8 0x3FE3AFCCFE77B9D1 //log(1/frcpa(1+ 217/256) 469data8 0x3FE3BE9D503533B5 //log(1/frcpa(1+ 218/256) 470data8 0x3FE3CD7480B4A8A3 //log(1/frcpa(1+ 219/256) 471data8 0x3FE3E3C43918F76C //log(1/frcpa(1+ 220/256) 472data8 0x3FE3F2ACB27ED6C7 //log(1/frcpa(1+ 221/256) 473data8 0x3FE4019C2125CA93 //log(1/frcpa(1+ 222/256) 474data8 0x3FE4181061389722 //log(1/frcpa(1+ 223/256) 475data8 0x3FE42711518DF545 //log(1/frcpa(1+ 224/256) 476data8 0x3FE436194E12B6BF //log(1/frcpa(1+ 225/256) 477data8 0x3FE445285D68EA69 //log(1/frcpa(1+ 226/256) 478data8 0x3FE45BCC464C893A //log(1/frcpa(1+ 227/256) 479data8 0x3FE46AED21F117FC //log(1/frcpa(1+ 228/256) 480data8 0x3FE47A1527E8A2D3 //log(1/frcpa(1+ 229/256) 481data8 0x3FE489445EFFFCCC //log(1/frcpa(1+ 230/256) 482data8 0x3FE4A018BCB69835 //log(1/frcpa(1+ 231/256) 483data8 0x3FE4AF5A0C9D65D7 //log(1/frcpa(1+ 232/256) 484data8 0x3FE4BEA2A5BDBE87 //log(1/frcpa(1+ 233/256) 485data8 0x3FE4CDF28F10AC46 //log(1/frcpa(1+ 234/256) 486data8 0x3FE4DD49CF994058 //log(1/frcpa(1+ 235/256) 487data8 0x3FE4ECA86E64A684 //log(1/frcpa(1+ 236/256) 488data8 0x3FE503C43CD8EB68 //log(1/frcpa(1+ 237/256) 489data8 0x3FE513356667FC57 //log(1/frcpa(1+ 238/256) 490data8 0x3FE522AE0738A3D8 //log(1/frcpa(1+ 239/256) 491data8 0x3FE5322E26867857 //log(1/frcpa(1+ 240/256) 492data8 0x3FE541B5CB979809 //log(1/frcpa(1+ 241/256) 493data8 0x3FE55144FDBCBD62 //log(1/frcpa(1+ 242/256) 494data8 0x3FE560DBC45153C7 //log(1/frcpa(1+ 243/256) 495data8 0x3FE5707A26BB8C66 //log(1/frcpa(1+ 244/256) 496data8 0x3FE587F60ED5B900 //log(1/frcpa(1+ 245/256) 497data8 0x3FE597A7977C8F31 //log(1/frcpa(1+ 246/256) 498data8 0x3FE5A760D634BB8B //log(1/frcpa(1+ 247/256) 499data8 0x3FE5B721D295F10F //log(1/frcpa(1+ 248/256) 500data8 0x3FE5C6EA94431EF9 //log(1/frcpa(1+ 249/256) 501data8 0x3FE5D6BB22EA86F6 //log(1/frcpa(1+ 250/256) 502data8 0x3FE5E6938645D390 //log(1/frcpa(1+ 251/256) 503data8 0x3FE5F673C61A2ED2 //log(1/frcpa(1+ 252/256) 504data8 0x3FE6065BEA385926 //log(1/frcpa(1+ 253/256) 505data8 0x3FE6164BFA7CC06B //log(1/frcpa(1+ 254/256) 506data8 0x3FE62643FECF9743 //log(1/frcpa(1+ 255/256) 507LOCAL_OBJECT_END(log_table_3) 508 509 510.section .text 511GLOBAL_LIBM_ENTRY(acoshf) 512 513{ .mfi 514 getf.exp acosh_GR_f8 = f8 515 fclass.m p6,p0 = f8, 0xc3 // Test for x = NaN 516 mov log_GR_comp2 = 0x10032 517} 518{ .mfi 519 addl NR_table_address = @ltoff(log_table_1), gp 520 fms.s1 log_y = f8, f8, f1 // y = x^2-1 521 nop.i 0 522} 523;; 524 525{ .mfi 526 getf.sig acosh_GR_f8_sig = f8 527 fclass.m p11,p0 = f8, 0x21 // Test for x=+inf 528 mov log_GR_exp_17_ones = 0x1ffff 529} 530{ .mfi 531 ld8 NR_table_address = [NR_table_address] 532 fms.s1 log_w = f8,f1,f1 // w = x - 1 533 nop.i 0 534} 535;; 536 537{ .mfi 538 nop.m 0 539 fcmp.lt.s1 p7,p8 = f8, f1 // Test for x<1.0 540 addl log_GR_comp = 0x10020C,r0 // Upper 21 bits of signif of 1.0005 541} 542{ .mfb 543 mov log_GR_exp_16_ones = 0xffff //BIAS 544(p6) fma.s.s0 f8 = f8,f1,f0 // quietize nan result if x=nan 545(p6) br.ret.spnt b0 // Exit for x=nan 546} 547;; 548 549{ .mfb 550 //get second table address 551 adds log_table_address2 = 0x20, NR_table_address 552 fcmp.eq.s1 p10,p0 = f8, f1 // Test for x=+1.0 553(p11) br.ret.spnt b0 // Exit for x=+inf 554} 555;; 556 557{ .mfi 558 ldfpd NR1,NR2 = [log_table_address2],16 559 frsqrta.s1 log_y_rs,p0 = log_y // z=1/sqrt(y) 560 nop.i 0 561} 562{ .mfb 563 nop.m 0 564 fma.s1 log_arg = f8,f1,f8 565(p7) br.cond.spnt ACOSH_LESS_ONE // Branch if path 7, x < 1.0 566} 567;; 568 569{ .mfi 570 ldfe log_C2 = [log_table_address2],16 571(p8) fcmp.eq.s0 p6,p0 = f8, f0 // Dummy op sets denorm flag if unorm>=1.0 572 nop.i 0 573} 574{ .mfb 575(p8) cmp.le.unc p13,p0 = log_GR_comp2,acosh_GR_f8 576 nop.f 0 577(p13) br.cond.spnt LOG_COMMON1 // Branch if path 4, x >= 2^51 578} 579;; 580 581{ .mfi 582 ldfe log_C1 = [log_table_address2],16 583(p10) fmerge.s f8 = f0, f0 // Return 0 if x=1.0 584 shr.u acosh_GR_f8_sig = acosh_GR_f8_sig,43 585} 586{ .mib 587 cmp.eq p14,p0 = log_GR_exp_16_ones,acosh_GR_f8 588 nop.i 0 589(p10) br.ret.spnt b0 // Exit for x=1.0 590} 591;; 592 593{ .mfi 594 ldfe log_C0 = [log_table_address2],16 595 frsqrta.s1 acosh_w_rs,p0 = log_w // t=1/sqrt(w) 596 nop.i 0 597} 598{ .mfb 599(p14) cmp.lt.unc p15,p0 = acosh_GR_f8_sig,log_GR_comp 600 nop.f 0 601(p15) br.cond.spnt ACOSH_NEAR_ONE // Branch if path 2, 1.0 < x < 1.0005 602} 603;; 604 605// Here is main path, 1.0005 <= x < 2^51 606/////////////// The first iteration ////////////////////////////////// 607{ .mfi 608 ldfpd log_P3,log_P2 = [NR_table_address],16 609 fma.s1 log_y_rs_iter = log_y_rs,log_y,f0 // y*z 610 nop.i 0 611} 612;; 613 614{ .mfi 615 ldfpd log_P1,log2 = [NR_table_address],16 616 fnma.s1 log_y_rs_iter2 = log_y_rs_iter,log_y_rs,NR2 // 3-(y*z)*z 617 nop.i 0 618} 619{ .mfi 620 nop.m 0 621 fma.s1 log_y_rs_iter1 = log_y_rs,NR1,f0 // 0.5*z 622 nop.i 0 623} 624;; 625 626{ .mfi 627 nop.m 0 628 // (0.5*z)*(3-(y*z)*z) 629 fma.s1 log_y_rs_iter = log_y_rs_iter1,log_y_rs_iter2,f0 630 nop.i 0 631} 632{ .mfi 633 nop.m 0 634 // (0.5*z)*(3-(y*z)*z) 635 fma.s1 log_arg_early = log_y_rs_iter1,log_y_rs_iter2,f0 636 nop.i 0 637} 638;; 639 640/////////////////////////// The second iteration ///////////////////////////// 641{ .mfi 642 nop.m 0 643 fma.s1 log_y_rs = log_y_rs_iter,log_y,f0 644 nop.i 0 645} 646{ .mfi 647 nop.m 0 648 fma.s1 log_y_rs_iter1 = log_y_rs_iter,NR1,f0 649 nop.i 0 650} 651;; 652 653{ .mfi 654 nop.m 0 655 fma.s1 log_arg_early = log_arg_early,log_y,f8 656 nop.i 0 657} 658;; 659 660{ .mfi 661 nop.m 0 662 fnma.s1 log_y_rs = log_y_rs,log_y_rs_iter,NR2 663 nop.i 0 664} 665{ .mfi 666 nop.m 0 667 fma.s1 log_y_rs_iter1 = log_y_rs_iter1,log_y,f0 668 nop.i 0 669} 670;; 671 672{ .mfi 673 nop.m 0 674 frcpa.s1 log_C,p0 = f1,log_arg_early 675 nop.i 0 676} 677;; 678 679{ .mfi 680 getf.exp log_GR_signexp_f8 = log_arg_early 681 nop.f 0 682 nop.i 0 683} 684;; 685 686{ .mfi 687 getf.sig log_GR_significand_f8 = log_arg_early 688 fma.s1 log_arg = log_y_rs_iter1,log_y_rs,f8 // (0.5*z)*(3-(y*z)*z) 689 adds log_table_address3 = 0x40, NR_table_address 690} 691;; 692 693///////////////////////////////// The end NR iterations ///////////////////// 694 695{ .mmi 696 //significant bit destruction 697 and log_GR_exp_f8 = log_GR_signexp_f8, log_GR_exp_17_ones 698;; 699 //BIAS subtraction 700 sub log_GR_true_exp_f8 = log_GR_exp_f8, log_GR_exp_16_ones 701 nop.i 0 702} 703;; 704 705{ .mfi 706 setf.sig log_int_Nfloat = log_GR_true_exp_f8 707 fms.s1 log_r = log_C,log_arg,f1 // C = frcpa(x); r = C * x - 1 708 extr.u log_GR_index = log_GR_significand_f8,55,8 //Extract 8 bits 709} 710;; 711 712{ .mmi 713 //pre-index*8 + index 714 shladd log_table_address3 = log_GR_index,3,log_table_address3 715;; 716 ldfd log_T = [log_table_address3] 717 nop.i 0 718} 719;; 720 721{ .mfi 722 nop.m 0 723 fma.s1 log_rsq = log_r, log_r, f0 //r^2 724 nop.i 0 725} 726{ .mfi 727 nop.m 0 728 fma.s1 log_rp_p32 = log_P3, log_r, log_P2 //P3*r + P2 729 nop.i 0 730} 731;; 732 733{ .mfi 734 nop.m 0 735 fma.s1 log_rp_p10 = log_P1, log_r, f1 //P1*r + 1.0 736 nop.i 0 737} 738;; 739 740{ .mfi 741 nop.m 0 742 //convert N to the floating-point format log_Nfloat 743 fcvt.xf log_Nfloat = log_int_Nfloat 744 nop.i 0 745} 746;; 747 748{ .mfi 749 nop.m 0 750 //(P3*r + P2)*r^2 + P1*r + 1.0 751 fma.s1 log_rp_p2 = log_rp_p32, log_rsq, log_rp_p10 752 nop.i 0 753} 754;; 755 756{ .mfi 757 nop.m 0 758 fma.s1 log_T_plus_Nlog2 = log_Nfloat,log2,log_T //N*log2 + T 759 nop.i 0 760} 761;; 762 763{ .mfb 764 nop.m 0 765 fma.s.s0 f8 = log_rp_p2,log_r,log_T_plus_Nlog2 766 br.ret.sptk b0 // Exit main path, path 3: 1.0005 <= x < 2^51 767} 768;; 769 770// Here if path 2, 1.0 < x < 1.0005 771ACOSH_NEAR_ONE: 772// The first NR iteration 773{ .mfi 774 nop.m 0 775 fma.s1 acosh_w_iter1 = acosh_w_rs,log_w,f0 //t*w 776 nop.i 0 777} 778{ .mfi 779 nop.m 0 780 fma.s1 acosh_w_1 = f8,log_C2,log_C1 //x*C2 + C1 781 nop.i 0 782} 783;; 784 785{ .mfi 786 nop.m 0 787 fma.s1 acosh_w_iter2 = acosh_w_rs,NR1,f0 //t*0.5 788 nop.i 0 789} 790{ .mfi 791 nop.m 0 792 fnma.s1 acosh_w_iter1 = acosh_w_iter1,acosh_w_rs,NR2 //3-t*t*w 793 nop.i 0 794} 795;; 796 797{ .mfi 798 nop.m 0 799 //(3-t*t*w)*t*0.5 800 fma.s1 acosh_w_iter2 = acosh_w_iter2,acosh_w_iter1,f0 801 nop.i 0 802} 803{ .mfi 804 nop.m 0 805 fma.s1 acosh_w_1 = acosh_w_1,log_w,log_C0 //(x*C2 + C1)*(x-1) + C0 806 nop.i 0 807} 808;; 809 810// The second NR iteration 811{ .mfi 812 nop.m 0 813 fma.s1 acosh_w_rs = acosh_w_iter2,log_w,f0 //t*w 814 nop.i 0 815} 816;; 817 818{ .mfi 819 nop.m 0 820 fnma.s1 acosh_w_iter1 = acosh_w_iter2,acosh_w_rs,NR2 821 nop.i 0 822} 823{ .mfi 824 nop.m 0 825 fma.s1 acosh_w_iter2 = acosh_w_iter2,NR1,f0 826 nop.i 0 827} 828;; 829 830{ .mfi 831 nop.m 0 832 fma.s1 acosh_w_iter2 = acosh_w_iter2,acosh_w_iter1,f0 833 nop.i 0 834} 835;; 836 837{ .mfi 838 nop.m 0 839 fma.s1 acosh_w_sqrt = acosh_w_iter2,log_w,f0 840 nop.i 0 841} 842;; 843 844{ .mfb 845 nop.m 0 846 fma.s.s0 f8 = acosh_w_1,acosh_w_sqrt,f0 847 br.ret.sptk b0 // Exit path 2, 1.0 < x < 1.0005 848} 849;; 850 851// Here if path 4, x >= 2^51 852LOG_COMMON1: 853{ .mfi 854 ldfpd log_P3,log_P2 = [NR_table_address],16 855 frcpa.s1 log_C,p0 = f1,log_arg 856 nop.i 0 857} 858;; 859 860{ .mmi 861 getf.exp log_GR_signexp_f8 = log_arg 862 ldfpd log_P1,log2 = [NR_table_address],16 863 nop.i 0 864} 865;; 866 867{ .mmi 868 getf.sig log_GR_significand_f8 = log_arg 869 nop.m 0 870 nop.i 0 871} 872;; 873 874{ .mfi 875 adds log_table_address3 = 0x40, NR_table_address 876 nop.f 0 877 //significant bit destruction 878 and log_GR_exp_f8 = log_GR_signexp_f8, log_GR_exp_17_ones 879} 880;; 881 882{ .mmf 883 nop.m 0 884 //BIAS subtraction 885 sub log_GR_true_exp_f8 = log_GR_exp_f8, log_GR_exp_16_ones 886 fms.s1 log_r = log_C,log_arg,f1 // C = frcpa(x); r = C * x - 1 887} 888;; 889 890{ .mfi 891 setf.sig log_int_Nfloat = log_GR_true_exp_f8 892 nop.f 0 893 extr.u log_GR_index = log_GR_significand_f8,55,8 //Extract 8 bits 894} 895;; 896 897{ .mmi 898 //pre-index*8 + index 899 shladd log_table_address3 = log_GR_index,3,log_table_address3 900;; 901 ldfd log_T = [log_table_address3] 902 nop.i 0 903} 904;; 905 906{ .mfi 907 nop.m 0 908 fma.s1 log_rsq = log_r, log_r, f0 //r^2 909 nop.i 0 910} 911{ .mfi 912 nop.m 0 913 fma.s1 log_rp_p32 = log_P3, log_r, log_P2 //P3*r + P2 914 nop.i 0 915} 916;; 917 918{ .mfi 919 nop.m 0 920 fma.s1 log_rp_p10 = log_P1, log_r, f1 //P1*r + 1.0 921 nop.i 0 922} 923;; 924 925{ .mfi 926 nop.m 0 927 //convert N to the floating-point format log_Nfloat 928 fcvt.xf log_Nfloat = log_int_Nfloat 929 nop.i 0 930} 931{ .mfi 932 nop.m 0 933 fma.s1 log_rp_p2 = log_rp_p32, log_rsq, log_rp_p10 934 nop.i 0 935} 936;; 937 938{ .mfi 939 nop.m 0 940 fma.s1 log_T_plus_Nlog2 = log_Nfloat,log2,log_T //N*log2 + T 941 nop.i 0 942} 943;; 944 945{ .mfb 946 nop.m 0 947 fma.s.s0 f8 = log_rp_p2,log_r,log_T_plus_Nlog2 948 br.ret.sptk b0 // Exit path 4, x >= 2^51 949} 950;; 951 952// Here if path 7, x < 1.0 953ACOSH_LESS_ONE: 954{ .mfi 955 alloc r32 = ar.pfs,1,3,4,0 956 fmerge.s f10 = f8,f8 957 nop.i 0 958} 959;; 960 961{ .mfb 962 mov acosh_GR_tag = 137 963 frcpa.s0 f8,p0 = f0,f0 964 br.cond.sptk __libm_error_region 965} 966;; 967 968GLOBAL_LIBM_END(acoshf) 969libm_alias_float_other (acosh, acosh) 970 971 972LOCAL_LIBM_ENTRY(__libm_error_region) 973.prologue 974 975{ .mfi 976 add GR_Parameter_Y=-32,sp // Parameter 2 value 977 nop.f 0 978.save ar.pfs,GR_SAVE_PFS 979 mov GR_SAVE_PFS=ar.pfs // Save ar.pfs 980} 981{ .mfi 982.fframe 64 983 add sp=-64,sp // Create new stack 984 nop.f 0 985 mov GR_SAVE_GP=gp // Save gp 986};; 987 988{ .mmi 989 stfs [GR_Parameter_Y] = f1,16 // STORE Parameter 2 on stack 990 add GR_Parameter_X = 16,sp // Parameter 1 address 991.save b0, GR_SAVE_B0 992 mov GR_SAVE_B0=b0 // Save b0 993};; 994 995.body 996{ .mib 997 stfs [GR_Parameter_X] = f10 // STORE Parameter 1 on stack 998 add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address 999 nop.b 0 1000} 1001{ .mib 1002 stfs [GR_Parameter_Y] = f8 // STORE Parameter 3 on stack 1003 add GR_Parameter_Y = -16,GR_Parameter_Y 1004 br.call.sptk b0=__libm_error_support# // Call error handling function 1005};; 1006 1007{ .mmi 1008 add GR_Parameter_RESULT = 48,sp 1009 nop.m 0 1010 nop.i 0 1011};; 1012 1013{ .mmi 1014 ldfs f8 = [GR_Parameter_RESULT] // Get return result off stack 1015.restore sp 1016 add sp = 64,sp // Restore stack pointer 1017 mov b0 = GR_SAVE_B0 // Restore return address 1018};; 1019 1020{ .mib 1021 mov gp = GR_SAVE_GP // Restore gp 1022 mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs 1023 br.ret.sptk b0 // Return 1024};; 1025 1026LOCAL_LIBM_END(__libm_error_region) 1027 1028 1029.type __libm_error_support#,@function 1030.global __libm_error_support# 1031