1b8021494Sopenharmony_ci// Copyright 2019, VIXL authors 2b8021494Sopenharmony_ci// All rights reserved. 3b8021494Sopenharmony_ci// 4b8021494Sopenharmony_ci// Redistribution and use in source and binary forms, with or without 5b8021494Sopenharmony_ci// modification, are permitted provided that the following conditions are met: 6b8021494Sopenharmony_ci// 7b8021494Sopenharmony_ci// * Redistributions of source code must retain the above copyright notice, 8b8021494Sopenharmony_ci// this list of conditions and the following disclaimer. 9b8021494Sopenharmony_ci// * Redistributions in binary form must reproduce the above copyright notice, 10b8021494Sopenharmony_ci// this list of conditions and the following disclaimer in the documentation 11b8021494Sopenharmony_ci// and/or other materials provided with the distribution. 12b8021494Sopenharmony_ci// * Neither the name of ARM Limited nor the names of its contributors may be 13b8021494Sopenharmony_ci// used to endorse or promote products derived from this software without 14b8021494Sopenharmony_ci// specific prior written permission. 15b8021494Sopenharmony_ci// 16b8021494Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND 17b8021494Sopenharmony_ci// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18b8021494Sopenharmony_ci// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19b8021494Sopenharmony_ci// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20b8021494Sopenharmony_ci// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21b8021494Sopenharmony_ci// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22b8021494Sopenharmony_ci// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23b8021494Sopenharmony_ci// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24b8021494Sopenharmony_ci// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25b8021494Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26b8021494Sopenharmony_ci 27b8021494Sopenharmony_ci#include <cfloat> 28b8021494Sopenharmony_ci#include <cmath> 29b8021494Sopenharmony_ci#include <cstdio> 30b8021494Sopenharmony_ci#include <cstdlib> 31b8021494Sopenharmony_ci#include <cstring> 32b8021494Sopenharmony_ci#include <sys/mman.h> 33b8021494Sopenharmony_ci 34b8021494Sopenharmony_ci#include "test-runner.h" 35b8021494Sopenharmony_ci#include "test-utils.h" 36b8021494Sopenharmony_ci 37b8021494Sopenharmony_ci#include "aarch64/cpu-aarch64.h" 38b8021494Sopenharmony_ci#include "aarch64/disasm-aarch64.h" 39b8021494Sopenharmony_ci#include "aarch64/macro-assembler-aarch64.h" 40b8021494Sopenharmony_ci#include "aarch64/simulator-aarch64.h" 41b8021494Sopenharmony_ci#include "aarch64/test-utils-aarch64.h" 42b8021494Sopenharmony_ci#include "test-assembler-aarch64.h" 43b8021494Sopenharmony_ci 44b8021494Sopenharmony_cinamespace vixl { 45b8021494Sopenharmony_cinamespace aarch64 { 46b8021494Sopenharmony_ci 47b8021494Sopenharmony_ciTEST(load_store_float) { 48b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 49b8021494Sopenharmony_ci 50b8021494Sopenharmony_ci float src[3] = {1.0, 2.0, 3.0}; 51b8021494Sopenharmony_ci float dst[3] = {0.0, 0.0, 0.0}; 52b8021494Sopenharmony_ci uintptr_t src_base = reinterpret_cast<uintptr_t>(src); 53b8021494Sopenharmony_ci uintptr_t dst_base = reinterpret_cast<uintptr_t>(dst); 54b8021494Sopenharmony_ci 55b8021494Sopenharmony_ci START(); 56b8021494Sopenharmony_ci __ Mov(x17, src_base); 57b8021494Sopenharmony_ci __ Mov(x18, dst_base); 58b8021494Sopenharmony_ci __ Mov(x19, src_base); 59b8021494Sopenharmony_ci __ Mov(x20, dst_base); 60b8021494Sopenharmony_ci __ Mov(x21, src_base); 61b8021494Sopenharmony_ci __ Mov(x22, dst_base); 62b8021494Sopenharmony_ci __ Ldr(s0, MemOperand(x17, sizeof(src[0]))); 63b8021494Sopenharmony_ci __ Str(s0, MemOperand(x18, sizeof(dst[0]), PostIndex)); 64b8021494Sopenharmony_ci __ Ldr(s1, MemOperand(x19, sizeof(src[0]), PostIndex)); 65b8021494Sopenharmony_ci __ Str(s1, MemOperand(x20, 2 * sizeof(dst[0]), PreIndex)); 66b8021494Sopenharmony_ci __ Ldr(s2, MemOperand(x21, 2 * sizeof(src[0]), PreIndex)); 67b8021494Sopenharmony_ci __ Str(s2, MemOperand(x22, sizeof(dst[0]))); 68b8021494Sopenharmony_ci END(); 69b8021494Sopenharmony_ci 70b8021494Sopenharmony_ci if (CAN_RUN()) { 71b8021494Sopenharmony_ci RUN(); 72b8021494Sopenharmony_ci 73b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s0); 74b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, dst[0]); 75b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 76b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, dst[2]); 77b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.0, s2); 78b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.0, dst[1]); 79b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base, x17); 80b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + sizeof(dst[0]), x18); 81b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + sizeof(src[0]), x19); 82b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + 2 * sizeof(dst[0]), x20); 83b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + 2 * sizeof(src[0]), x21); 84b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base, x22); 85b8021494Sopenharmony_ci } 86b8021494Sopenharmony_ci} 87b8021494Sopenharmony_ci 88b8021494Sopenharmony_ci 89b8021494Sopenharmony_ciTEST(load_store_double) { 90b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 91b8021494Sopenharmony_ci 92b8021494Sopenharmony_ci double src[3] = {1.0, 2.0, 3.0}; 93b8021494Sopenharmony_ci double dst[3] = {0.0, 0.0, 0.0}; 94b8021494Sopenharmony_ci uintptr_t src_base = reinterpret_cast<uintptr_t>(src); 95b8021494Sopenharmony_ci uintptr_t dst_base = reinterpret_cast<uintptr_t>(dst); 96b8021494Sopenharmony_ci 97b8021494Sopenharmony_ci START(); 98b8021494Sopenharmony_ci __ Mov(x17, src_base); 99b8021494Sopenharmony_ci __ Mov(x18, dst_base); 100b8021494Sopenharmony_ci __ Mov(x19, src_base); 101b8021494Sopenharmony_ci __ Mov(x20, dst_base); 102b8021494Sopenharmony_ci __ Mov(x21, src_base); 103b8021494Sopenharmony_ci __ Mov(x22, dst_base); 104b8021494Sopenharmony_ci __ Ldr(d0, MemOperand(x17, sizeof(src[0]))); 105b8021494Sopenharmony_ci __ Str(d0, MemOperand(x18, sizeof(dst[0]), PostIndex)); 106b8021494Sopenharmony_ci __ Ldr(d1, MemOperand(x19, sizeof(src[0]), PostIndex)); 107b8021494Sopenharmony_ci __ Str(d1, MemOperand(x20, 2 * sizeof(dst[0]), PreIndex)); 108b8021494Sopenharmony_ci __ Ldr(d2, MemOperand(x21, 2 * sizeof(src[0]), PreIndex)); 109b8021494Sopenharmony_ci __ Str(d2, MemOperand(x22, sizeof(dst[0]))); 110b8021494Sopenharmony_ci END(); 111b8021494Sopenharmony_ci 112b8021494Sopenharmony_ci if (CAN_RUN()) { 113b8021494Sopenharmony_ci RUN(); 114b8021494Sopenharmony_ci 115b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d0); 116b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, dst[0]); 117b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d1); 118b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, dst[2]); 119b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.0, d2); 120b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.0, dst[1]); 121b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base, x17); 122b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + sizeof(dst[0]), x18); 123b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + sizeof(src[0]), x19); 124b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + 2 * sizeof(dst[0]), x20); 125b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + 2 * sizeof(src[0]), x21); 126b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base, x22); 127b8021494Sopenharmony_ci } 128b8021494Sopenharmony_ci} 129b8021494Sopenharmony_ci 130b8021494Sopenharmony_ciTEST(ldp_stp_float) { 131b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 132b8021494Sopenharmony_ci 133b8021494Sopenharmony_ci float src[2] = {1.0, 2.0}; 134b8021494Sopenharmony_ci float dst[3] = {0.0, 0.0, 0.0}; 135b8021494Sopenharmony_ci uintptr_t src_base = reinterpret_cast<uintptr_t>(src); 136b8021494Sopenharmony_ci uintptr_t dst_base = reinterpret_cast<uintptr_t>(dst); 137b8021494Sopenharmony_ci 138b8021494Sopenharmony_ci START(); 139b8021494Sopenharmony_ci __ Mov(x16, src_base); 140b8021494Sopenharmony_ci __ Mov(x17, dst_base); 141b8021494Sopenharmony_ci __ Ldp(s31, s0, MemOperand(x16, 2 * sizeof(src[0]), PostIndex)); 142b8021494Sopenharmony_ci __ Stp(s0, s31, MemOperand(x17, sizeof(dst[1]), PreIndex)); 143b8021494Sopenharmony_ci END(); 144b8021494Sopenharmony_ci 145b8021494Sopenharmony_ci if (CAN_RUN()) { 146b8021494Sopenharmony_ci RUN(); 147b8021494Sopenharmony_ci 148b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s31); 149b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s0); 150b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, dst[0]); 151b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, dst[1]); 152b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, dst[2]); 153b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + 2 * sizeof(src[0]), x16); 154b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + sizeof(dst[1]), x17); 155b8021494Sopenharmony_ci } 156b8021494Sopenharmony_ci} 157b8021494Sopenharmony_ci 158b8021494Sopenharmony_ci 159b8021494Sopenharmony_ciTEST(ldp_stp_double) { 160b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 161b8021494Sopenharmony_ci 162b8021494Sopenharmony_ci double src[2] = {1.0, 2.0}; 163b8021494Sopenharmony_ci double dst[3] = {0.0, 0.0, 0.0}; 164b8021494Sopenharmony_ci uintptr_t src_base = reinterpret_cast<uintptr_t>(src); 165b8021494Sopenharmony_ci uintptr_t dst_base = reinterpret_cast<uintptr_t>(dst); 166b8021494Sopenharmony_ci 167b8021494Sopenharmony_ci START(); 168b8021494Sopenharmony_ci __ Mov(x16, src_base); 169b8021494Sopenharmony_ci __ Mov(x17, dst_base); 170b8021494Sopenharmony_ci __ Ldp(d31, d0, MemOperand(x16, 2 * sizeof(src[0]), PostIndex)); 171b8021494Sopenharmony_ci __ Stp(d0, d31, MemOperand(x17, sizeof(dst[1]), PreIndex)); 172b8021494Sopenharmony_ci END(); 173b8021494Sopenharmony_ci 174b8021494Sopenharmony_ci if (CAN_RUN()) { 175b8021494Sopenharmony_ci RUN(); 176b8021494Sopenharmony_ci 177b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d31); 178b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d0); 179b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, dst[0]); 180b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, dst[1]); 181b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, dst[2]); 182b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + 2 * sizeof(src[0]), x16); 183b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + sizeof(dst[1]), x17); 184b8021494Sopenharmony_ci } 185b8021494Sopenharmony_ci} 186b8021494Sopenharmony_ci 187b8021494Sopenharmony_ciTEST(ldnp_stnp_offset_float) { 188b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 189b8021494Sopenharmony_ci 190b8021494Sopenharmony_ci float src[3] = {1.2, 2.3, 3.4}; 191b8021494Sopenharmony_ci float dst[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; 192b8021494Sopenharmony_ci uintptr_t src_base = reinterpret_cast<uintptr_t>(src); 193b8021494Sopenharmony_ci uintptr_t dst_base = reinterpret_cast<uintptr_t>(dst); 194b8021494Sopenharmony_ci 195b8021494Sopenharmony_ci START(); 196b8021494Sopenharmony_ci __ Mov(x16, src_base); 197b8021494Sopenharmony_ci __ Mov(x17, dst_base); 198b8021494Sopenharmony_ci __ Mov(x18, src_base + 12); 199b8021494Sopenharmony_ci __ Mov(x19, dst_base + 24); 200b8021494Sopenharmony_ci 201b8021494Sopenharmony_ci // Ensure address set up has happened before executing non-temporal ops. 202b8021494Sopenharmony_ci __ Dmb(InnerShareable, BarrierAll); 203b8021494Sopenharmony_ci 204b8021494Sopenharmony_ci __ Ldnp(s0, s1, MemOperand(x16)); 205b8021494Sopenharmony_ci __ Ldnp(s2, s3, MemOperand(x16, 4)); 206b8021494Sopenharmony_ci __ Ldnp(s5, s4, MemOperand(x18, -8)); 207b8021494Sopenharmony_ci __ Stnp(s1, s0, MemOperand(x17)); 208b8021494Sopenharmony_ci __ Stnp(s3, s2, MemOperand(x17, 8)); 209b8021494Sopenharmony_ci __ Stnp(s4, s5, MemOperand(x19, -8)); 210b8021494Sopenharmony_ci END(); 211b8021494Sopenharmony_ci 212b8021494Sopenharmony_ci if (CAN_RUN()) { 213b8021494Sopenharmony_ci RUN(); 214b8021494Sopenharmony_ci 215b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.2, s0); 216b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.3, s1); 217b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.3, dst[0]); 218b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.2, dst[1]); 219b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.3, s2); 220b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.4, s3); 221b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.4, dst[2]); 222b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.3, dst[3]); 223b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.4, s4); 224b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.3, s5); 225b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.4, dst[4]); 226b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.3, dst[5]); 227b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base, x16); 228b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base, x17); 229b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + 12, x18); 230b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + 24, x19); 231b8021494Sopenharmony_ci } 232b8021494Sopenharmony_ci} 233b8021494Sopenharmony_ci 234b8021494Sopenharmony_ci 235b8021494Sopenharmony_ciTEST(ldnp_stnp_offset_double) { 236b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 237b8021494Sopenharmony_ci 238b8021494Sopenharmony_ci double src[3] = {1.2, 2.3, 3.4}; 239b8021494Sopenharmony_ci double dst[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; 240b8021494Sopenharmony_ci uintptr_t src_base = reinterpret_cast<uintptr_t>(src); 241b8021494Sopenharmony_ci uintptr_t dst_base = reinterpret_cast<uintptr_t>(dst); 242b8021494Sopenharmony_ci 243b8021494Sopenharmony_ci START(); 244b8021494Sopenharmony_ci __ Mov(x16, src_base); 245b8021494Sopenharmony_ci __ Mov(x17, dst_base); 246b8021494Sopenharmony_ci __ Mov(x18, src_base + 24); 247b8021494Sopenharmony_ci __ Mov(x19, dst_base + 48); 248b8021494Sopenharmony_ci 249b8021494Sopenharmony_ci // Ensure address set up has happened before executing non-temporal ops. 250b8021494Sopenharmony_ci __ Dmb(InnerShareable, BarrierAll); 251b8021494Sopenharmony_ci 252b8021494Sopenharmony_ci __ Ldnp(d0, d1, MemOperand(x16)); 253b8021494Sopenharmony_ci __ Ldnp(d2, d3, MemOperand(x16, 8)); 254b8021494Sopenharmony_ci __ Ldnp(d5, d4, MemOperand(x18, -16)); 255b8021494Sopenharmony_ci __ Stnp(d1, d0, MemOperand(x17)); 256b8021494Sopenharmony_ci __ Stnp(d3, d2, MemOperand(x17, 16)); 257b8021494Sopenharmony_ci __ Stnp(d4, d5, MemOperand(x19, -16)); 258b8021494Sopenharmony_ci END(); 259b8021494Sopenharmony_ci 260b8021494Sopenharmony_ci if (CAN_RUN()) { 261b8021494Sopenharmony_ci RUN(); 262b8021494Sopenharmony_ci 263b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.2, d0); 264b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.3, d1); 265b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.3, dst[0]); 266b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.2, dst[1]); 267b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.3, d2); 268b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.4, d3); 269b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.4, dst[2]); 270b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.3, dst[3]); 271b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.4, d4); 272b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.3, d5); 273b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.4, dst[4]); 274b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.3, dst[5]); 275b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base, x16); 276b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base, x17); 277b8021494Sopenharmony_ci ASSERT_EQUAL_64(src_base + 24, x18); 278b8021494Sopenharmony_ci ASSERT_EQUAL_64(dst_base + 48, x19); 279b8021494Sopenharmony_ci } 280b8021494Sopenharmony_ci} 281b8021494Sopenharmony_ci 282b8021494Sopenharmony_citemplate <typename T> 283b8021494Sopenharmony_civoid LoadFPValueHelper(T values[], int card) { 284b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 285b8021494Sopenharmony_ci 286b8021494Sopenharmony_ci const bool is_32bits = (sizeof(T) == 4); 287b8021494Sopenharmony_ci const VRegister& fp_tgt = is_32bits ? VRegister(s2) : VRegister(d2); 288b8021494Sopenharmony_ci const Register& tgt1 = is_32bits ? Register(w1) : Register(x1); 289b8021494Sopenharmony_ci const Register& tgt2 = is_32bits ? Register(w2) : Register(x2); 290b8021494Sopenharmony_ci 291b8021494Sopenharmony_ci START(); 292b8021494Sopenharmony_ci __ Mov(x0, 0); 293b8021494Sopenharmony_ci 294b8021494Sopenharmony_ci // If one of the values differ then x0 will be one. 295b8021494Sopenharmony_ci for (int i = 0; i < card; ++i) { 296b8021494Sopenharmony_ci __ Mov(tgt1, 297b8021494Sopenharmony_ci is_32bits ? FloatToRawbits(values[i]) : DoubleToRawbits(values[i])); 298b8021494Sopenharmony_ci __ Ldr(fp_tgt, values[i]); 299b8021494Sopenharmony_ci __ Fmov(tgt2, fp_tgt); 300b8021494Sopenharmony_ci __ Cmp(tgt1, tgt2); 301b8021494Sopenharmony_ci __ Cset(x0, ne); 302b8021494Sopenharmony_ci } 303b8021494Sopenharmony_ci END(); 304b8021494Sopenharmony_ci 305b8021494Sopenharmony_ci if (CAN_RUN()) { 306b8021494Sopenharmony_ci RUN(); 307b8021494Sopenharmony_ci 308b8021494Sopenharmony_ci // If one of the values differs, the trace can be used to identify which 309b8021494Sopenharmony_ci // one. 310b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x0); 311b8021494Sopenharmony_ci } 312b8021494Sopenharmony_ci} 313b8021494Sopenharmony_ci 314b8021494Sopenharmony_ciTEST(ldr_literal_values_d) { 315b8021494Sopenharmony_ci static const double kValues[] = {-0.0, 0.0, -1.0, 1.0, -1e10, 1e10}; 316b8021494Sopenharmony_ci 317b8021494Sopenharmony_ci LoadFPValueHelper(kValues, sizeof(kValues) / sizeof(kValues[0])); 318b8021494Sopenharmony_ci} 319b8021494Sopenharmony_ci 320b8021494Sopenharmony_ci 321b8021494Sopenharmony_ciTEST(ldr_literal_values_s) { 322b8021494Sopenharmony_ci static const float kValues[] = {-0.0, 0.0, -1.0, 1.0, -1e10, 1e10}; 323b8021494Sopenharmony_ci 324b8021494Sopenharmony_ci LoadFPValueHelper(kValues, sizeof(kValues) / sizeof(kValues[0])); 325b8021494Sopenharmony_ci} 326b8021494Sopenharmony_ci 327b8021494Sopenharmony_ciTEST(fmov_imm) { 328b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 329b8021494Sopenharmony_ci 330b8021494Sopenharmony_ci START(); 331b8021494Sopenharmony_ci __ Fmov(s1, 255.0); 332b8021494Sopenharmony_ci __ Fmov(d2, 12.34567); 333b8021494Sopenharmony_ci __ Fmov(s3, 0.0); 334b8021494Sopenharmony_ci __ Fmov(d4, 0.0); 335b8021494Sopenharmony_ci __ Fmov(s5, kFP32PositiveInfinity); 336b8021494Sopenharmony_ci __ Fmov(d6, kFP64NegativeInfinity); 337b8021494Sopenharmony_ci __ Fmov(h7, RawbitsToFloat16(0x6400U)); 338b8021494Sopenharmony_ci __ Fmov(h8, kFP16PositiveInfinity); 339b8021494Sopenharmony_ci __ Fmov(s11, 1.0); 340b8021494Sopenharmony_ci __ Fmov(h12, RawbitsToFloat16(0x7BFF)); 341b8021494Sopenharmony_ci __ Fmov(h13, RawbitsToFloat16(0x57F2)); 342b8021494Sopenharmony_ci __ Fmov(d22, -13.0); 343b8021494Sopenharmony_ci __ Fmov(h23, RawbitsToFloat16(0xC500U)); 344b8021494Sopenharmony_ci __ Fmov(h24, Float16(-5.0)); 345b8021494Sopenharmony_ci __ Fmov(h25, Float16(2049.0)); 346b8021494Sopenharmony_ci __ Fmov(h21, RawbitsToFloat16(0x6404U)); 347b8021494Sopenharmony_ci __ Fmov(h26, RawbitsToFloat16(0x0U)); 348b8021494Sopenharmony_ci __ Fmov(h27, RawbitsToFloat16(0x7e00U)); 349b8021494Sopenharmony_ci END(); 350b8021494Sopenharmony_ci if (CAN_RUN()) { 351b8021494Sopenharmony_ci RUN(); 352b8021494Sopenharmony_ci 353b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(255.0, s1); 354b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(12.34567, d2); 355b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s3); 356b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d4); 357b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s5); 358b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d6); 359b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0x6400U), h7); 360b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16PositiveInfinity, h8); 361b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s11); 362b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0x7BFF), h12); 363b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0x57F2U), h13); 364b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0x6404), h21); 365b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-13.0, d22); 366b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(-5.0), h23); 367b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0xC500), h24); 368b8021494Sopenharmony_ci // 2049 is unpresentable. 369b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0x6800), h25); 370b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16PositiveZero, h26); 371b8021494Sopenharmony_ci // NaN check. 372b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0x7e00), h27); 373b8021494Sopenharmony_ci } 374b8021494Sopenharmony_ci} 375b8021494Sopenharmony_ci 376b8021494Sopenharmony_ciTEST(fmov_reg) { 377b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kNEON, 378b8021494Sopenharmony_ci CPUFeatures::kFP, 379b8021494Sopenharmony_ci CPUFeatures::kFPHalf); 380b8021494Sopenharmony_ci 381b8021494Sopenharmony_ci START(); 382b8021494Sopenharmony_ci 383b8021494Sopenharmony_ci __ Fmov(h3, RawbitsToFloat16(0xCA80U)); 384b8021494Sopenharmony_ci __ Fmov(h7, h3); 385b8021494Sopenharmony_ci __ Fmov(h8, -5.0); 386b8021494Sopenharmony_ci __ Fmov(w3, h8); 387b8021494Sopenharmony_ci __ Fmov(h9, w3); 388b8021494Sopenharmony_ci __ Fmov(h8, Float16(1024.0)); 389b8021494Sopenharmony_ci __ Fmov(x4, h8); 390b8021494Sopenharmony_ci __ Fmov(h10, x4); 391b8021494Sopenharmony_ci __ Fmov(s20, 1.0); 392b8021494Sopenharmony_ci __ Fmov(w10, s20); 393b8021494Sopenharmony_ci __ Fmov(s30, w10); 394b8021494Sopenharmony_ci __ Fmov(s5, s20); 395b8021494Sopenharmony_ci __ Fmov(d1, -13.0); 396b8021494Sopenharmony_ci __ Fmov(x1, d1); 397b8021494Sopenharmony_ci __ Fmov(d2, x1); 398b8021494Sopenharmony_ci __ Fmov(d4, d1); 399b8021494Sopenharmony_ci __ Fmov(d6, RawbitsToDouble(0x0123456789abcdef)); 400b8021494Sopenharmony_ci __ Fmov(s6, s6); 401b8021494Sopenharmony_ci __ Fmov(d0, 0.0); 402b8021494Sopenharmony_ci __ Fmov(v0.D(), 1, x1); 403b8021494Sopenharmony_ci __ Fmov(x2, v0.D(), 1); 404b8021494Sopenharmony_ci __ Fmov(v3.D(), 1, x4); 405b8021494Sopenharmony_ci __ Fmov(v3.D(), 0, x1); 406b8021494Sopenharmony_ci __ Fmov(x5, v1.D(), 0); 407b8021494Sopenharmony_ci 408b8021494Sopenharmony_ci END(); 409b8021494Sopenharmony_ci if (CAN_RUN()) { 410b8021494Sopenharmony_ci RUN(); 411b8021494Sopenharmony_ci 412b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0xCA80U), h7); 413b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0xC500U), h9); 414b8021494Sopenharmony_ci ASSERT_EQUAL_32(0x0000C500, w3); 415b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x0000000000006400, x4); 416b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0x6400), h10); 417b8021494Sopenharmony_ci ASSERT_EQUAL_32(FloatToRawbits(1.0), w10); 418b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s30); 419b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s5); 420b8021494Sopenharmony_ci ASSERT_EQUAL_64(DoubleToRawbits(-13.0), x1); 421b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-13.0, d2); 422b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-13.0, d4); 423b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(0x89abcdef), s6); 424b8021494Sopenharmony_ci ASSERT_EQUAL_128(DoubleToRawbits(-13.0), 0x0000000000000000, q0); 425b8021494Sopenharmony_ci ASSERT_EQUAL_64(DoubleToRawbits(-13.0), x2); 426b8021494Sopenharmony_ci ASSERT_EQUAL_128(0x0000000000006400, DoubleToRawbits(-13.0), q3); 427b8021494Sopenharmony_ci ASSERT_EQUAL_64(DoubleToRawbits(-13.0), x5); 428b8021494Sopenharmony_ci } 429b8021494Sopenharmony_ci} 430b8021494Sopenharmony_ci 431b8021494Sopenharmony_ci 432b8021494Sopenharmony_ciTEST(fadd) { 433b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 434b8021494Sopenharmony_ci 435b8021494Sopenharmony_ci START(); 436b8021494Sopenharmony_ci __ Fmov(s14, -0.0f); 437b8021494Sopenharmony_ci __ Fmov(s15, kFP32PositiveInfinity); 438b8021494Sopenharmony_ci __ Fmov(s16, kFP32NegativeInfinity); 439b8021494Sopenharmony_ci __ Fmov(s17, 3.25f); 440b8021494Sopenharmony_ci __ Fmov(s18, 1.0f); 441b8021494Sopenharmony_ci __ Fmov(s19, 0.0f); 442b8021494Sopenharmony_ci 443b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 444b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 445b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 446b8021494Sopenharmony_ci __ Fmov(d29, 0.0); 447b8021494Sopenharmony_ci __ Fmov(d30, -2.0); 448b8021494Sopenharmony_ci __ Fmov(d31, 2.25); 449b8021494Sopenharmony_ci 450b8021494Sopenharmony_ci __ Fadd(s0, s17, s18); 451b8021494Sopenharmony_ci __ Fadd(s1, s18, s19); 452b8021494Sopenharmony_ci __ Fadd(s2, s14, s18); 453b8021494Sopenharmony_ci __ Fadd(s3, s15, s18); 454b8021494Sopenharmony_ci __ Fadd(s4, s16, s18); 455b8021494Sopenharmony_ci __ Fadd(s5, s15, s16); 456b8021494Sopenharmony_ci __ Fadd(s6, s16, s15); 457b8021494Sopenharmony_ci 458b8021494Sopenharmony_ci __ Fadd(d7, d30, d31); 459b8021494Sopenharmony_ci __ Fadd(d8, d29, d31); 460b8021494Sopenharmony_ci __ Fadd(d9, d26, d31); 461b8021494Sopenharmony_ci __ Fadd(d10, d27, d31); 462b8021494Sopenharmony_ci __ Fadd(d11, d28, d31); 463b8021494Sopenharmony_ci __ Fadd(d12, d27, d28); 464b8021494Sopenharmony_ci __ Fadd(d13, d28, d27); 465b8021494Sopenharmony_ci END(); 466b8021494Sopenharmony_ci 467b8021494Sopenharmony_ci if (CAN_RUN()) { 468b8021494Sopenharmony_ci RUN(); 469b8021494Sopenharmony_ci 470b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(4.25, s0); 471b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 472b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s2); 473b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s3); 474b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s4); 475b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s5); 476b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s6); 477b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.25, d7); 478b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.25, d8); 479b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.25, d9); 480b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d10); 481b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d11); 482b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d12); 483b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d13); 484b8021494Sopenharmony_ci } 485b8021494Sopenharmony_ci} 486b8021494Sopenharmony_ci 487b8021494Sopenharmony_ci 488b8021494Sopenharmony_ciTEST(fadd_h) { 489b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 490b8021494Sopenharmony_ci 491b8021494Sopenharmony_ci START(); 492b8021494Sopenharmony_ci __ Fmov(h14, -0.0f); 493b8021494Sopenharmony_ci __ Fmov(h15, kFP16PositiveInfinity); 494b8021494Sopenharmony_ci __ Fmov(h16, kFP16NegativeInfinity); 495b8021494Sopenharmony_ci __ Fmov(h17, 3.25f); 496b8021494Sopenharmony_ci __ Fmov(h18, 1.0); 497b8021494Sopenharmony_ci __ Fmov(h19, 0.0f); 498b8021494Sopenharmony_ci __ Fmov(h20, 5.0f); 499b8021494Sopenharmony_ci 500b8021494Sopenharmony_ci __ Fadd(h0, h17, h18); 501b8021494Sopenharmony_ci __ Fadd(h1, h18, h19); 502b8021494Sopenharmony_ci __ Fadd(h2, h14, h18); 503b8021494Sopenharmony_ci __ Fadd(h3, h15, h18); 504b8021494Sopenharmony_ci __ Fadd(h4, h16, h18); 505b8021494Sopenharmony_ci __ Fadd(h5, h15, h16); 506b8021494Sopenharmony_ci __ Fadd(h6, h16, h15); 507b8021494Sopenharmony_ci __ Fadd(h7, h20, h20); 508b8021494Sopenharmony_ci END(); 509b8021494Sopenharmony_ci 510b8021494Sopenharmony_ci if (CAN_RUN()) { 511b8021494Sopenharmony_ci RUN(); 512b8021494Sopenharmony_ci 513b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(4.25), h0); 514b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.0), h1); 515b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.0), h2); 516b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16PositiveInfinity, h3); 517b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16NegativeInfinity, h4); 518b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h5); 519b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h6); 520b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(10.0), h7); 521b8021494Sopenharmony_ci } 522b8021494Sopenharmony_ci} 523b8021494Sopenharmony_ci 524b8021494Sopenharmony_ciTEST(fsub) { 525b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 526b8021494Sopenharmony_ci 527b8021494Sopenharmony_ci START(); 528b8021494Sopenharmony_ci __ Fmov(s14, -0.0f); 529b8021494Sopenharmony_ci __ Fmov(s15, kFP32PositiveInfinity); 530b8021494Sopenharmony_ci __ Fmov(s16, kFP32NegativeInfinity); 531b8021494Sopenharmony_ci __ Fmov(s17, 3.25f); 532b8021494Sopenharmony_ci __ Fmov(s18, 1.0f); 533b8021494Sopenharmony_ci __ Fmov(s19, 0.0f); 534b8021494Sopenharmony_ci 535b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 536b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 537b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 538b8021494Sopenharmony_ci __ Fmov(d29, 0.0); 539b8021494Sopenharmony_ci __ Fmov(d30, -2.0); 540b8021494Sopenharmony_ci __ Fmov(d31, 2.25); 541b8021494Sopenharmony_ci 542b8021494Sopenharmony_ci __ Fsub(s0, s17, s18); 543b8021494Sopenharmony_ci __ Fsub(s1, s18, s19); 544b8021494Sopenharmony_ci __ Fsub(s2, s14, s18); 545b8021494Sopenharmony_ci __ Fsub(s3, s18, s15); 546b8021494Sopenharmony_ci __ Fsub(s4, s18, s16); 547b8021494Sopenharmony_ci __ Fsub(s5, s15, s15); 548b8021494Sopenharmony_ci __ Fsub(s6, s16, s16); 549b8021494Sopenharmony_ci 550b8021494Sopenharmony_ci __ Fsub(d7, d30, d31); 551b8021494Sopenharmony_ci __ Fsub(d8, d29, d31); 552b8021494Sopenharmony_ci __ Fsub(d9, d26, d31); 553b8021494Sopenharmony_ci __ Fsub(d10, d31, d27); 554b8021494Sopenharmony_ci __ Fsub(d11, d31, d28); 555b8021494Sopenharmony_ci __ Fsub(d12, d27, d27); 556b8021494Sopenharmony_ci __ Fsub(d13, d28, d28); 557b8021494Sopenharmony_ci END(); 558b8021494Sopenharmony_ci 559b8021494Sopenharmony_ci if (CAN_RUN()) { 560b8021494Sopenharmony_ci RUN(); 561b8021494Sopenharmony_ci 562b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.25, s0); 563b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 564b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.0, s2); 565b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s3); 566b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s4); 567b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s5); 568b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s6); 569b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-4.25, d7); 570b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.25, d8); 571b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.25, d9); 572b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d10); 573b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d11); 574b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d12); 575b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d13); 576b8021494Sopenharmony_ci } 577b8021494Sopenharmony_ci} 578b8021494Sopenharmony_ci 579b8021494Sopenharmony_ci 580b8021494Sopenharmony_ciTEST(fsub_h) { 581b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 582b8021494Sopenharmony_ci 583b8021494Sopenharmony_ci START(); 584b8021494Sopenharmony_ci __ Fmov(h14, -0.0f); 585b8021494Sopenharmony_ci __ Fmov(h15, kFP16PositiveInfinity); 586b8021494Sopenharmony_ci __ Fmov(h16, kFP16NegativeInfinity); 587b8021494Sopenharmony_ci __ Fmov(h17, 3.25f); 588b8021494Sopenharmony_ci __ Fmov(h18, 1.0f); 589b8021494Sopenharmony_ci __ Fmov(h19, 0.0f); 590b8021494Sopenharmony_ci 591b8021494Sopenharmony_ci __ Fsub(h0, h17, h18); 592b8021494Sopenharmony_ci __ Fsub(h1, h18, h19); 593b8021494Sopenharmony_ci __ Fsub(h2, h14, h18); 594b8021494Sopenharmony_ci __ Fsub(h3, h18, h15); 595b8021494Sopenharmony_ci __ Fsub(h4, h18, h16); 596b8021494Sopenharmony_ci __ Fsub(h5, h15, h15); 597b8021494Sopenharmony_ci __ Fsub(h6, h16, h16); 598b8021494Sopenharmony_ci END(); 599b8021494Sopenharmony_ci 600b8021494Sopenharmony_ci if (CAN_RUN()) { 601b8021494Sopenharmony_ci RUN(); 602b8021494Sopenharmony_ci 603b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(2.25), h0); 604b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.0), h1); 605b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(-1.0), h2); 606b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16NegativeInfinity, h3); 607b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16PositiveInfinity, h4); 608b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h5); 609b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h6); 610b8021494Sopenharmony_ci } 611b8021494Sopenharmony_ci} 612b8021494Sopenharmony_ci 613b8021494Sopenharmony_ci 614b8021494Sopenharmony_ciTEST(fmul) { 615b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 616b8021494Sopenharmony_ci 617b8021494Sopenharmony_ci START(); 618b8021494Sopenharmony_ci __ Fmov(s14, -0.0f); 619b8021494Sopenharmony_ci __ Fmov(s15, kFP32PositiveInfinity); 620b8021494Sopenharmony_ci __ Fmov(s16, kFP32NegativeInfinity); 621b8021494Sopenharmony_ci __ Fmov(s17, 3.25f); 622b8021494Sopenharmony_ci __ Fmov(s18, 2.0f); 623b8021494Sopenharmony_ci __ Fmov(s19, 0.0f); 624b8021494Sopenharmony_ci __ Fmov(s20, -2.0f); 625b8021494Sopenharmony_ci 626b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 627b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 628b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 629b8021494Sopenharmony_ci __ Fmov(d29, 0.0); 630b8021494Sopenharmony_ci __ Fmov(d30, -2.0); 631b8021494Sopenharmony_ci __ Fmov(d31, 2.25); 632b8021494Sopenharmony_ci 633b8021494Sopenharmony_ci __ Fmul(s0, s17, s18); 634b8021494Sopenharmony_ci __ Fmul(s1, s18, s19); 635b8021494Sopenharmony_ci __ Fmul(s2, s14, s14); 636b8021494Sopenharmony_ci __ Fmul(s3, s15, s20); 637b8021494Sopenharmony_ci __ Fmul(s4, s16, s20); 638b8021494Sopenharmony_ci __ Fmul(s5, s15, s19); 639b8021494Sopenharmony_ci __ Fmul(s6, s19, s16); 640b8021494Sopenharmony_ci 641b8021494Sopenharmony_ci __ Fmul(d7, d30, d31); 642b8021494Sopenharmony_ci __ Fmul(d8, d29, d31); 643b8021494Sopenharmony_ci __ Fmul(d9, d26, d26); 644b8021494Sopenharmony_ci __ Fmul(d10, d27, d30); 645b8021494Sopenharmony_ci __ Fmul(d11, d28, d30); 646b8021494Sopenharmony_ci __ Fmul(d12, d27, d29); 647b8021494Sopenharmony_ci __ Fmul(d13, d29, d28); 648b8021494Sopenharmony_ci END(); 649b8021494Sopenharmony_ci 650b8021494Sopenharmony_ci if (CAN_RUN()) { 651b8021494Sopenharmony_ci RUN(); 652b8021494Sopenharmony_ci 653b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(6.5, s0); 654b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s1); 655b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s2); 656b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s3); 657b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s4); 658b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s5); 659b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s6); 660b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-4.5, d7); 661b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d8); 662b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d9); 663b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d10); 664b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d11); 665b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d12); 666b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d13); 667b8021494Sopenharmony_ci } 668b8021494Sopenharmony_ci} 669b8021494Sopenharmony_ci 670b8021494Sopenharmony_ci 671b8021494Sopenharmony_ciTEST(fmul_h) { 672b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 673b8021494Sopenharmony_ci 674b8021494Sopenharmony_ci START(); 675b8021494Sopenharmony_ci __ Fmov(h14, -0.0f); 676b8021494Sopenharmony_ci __ Fmov(h15, kFP16PositiveInfinity); 677b8021494Sopenharmony_ci __ Fmov(h16, kFP16NegativeInfinity); 678b8021494Sopenharmony_ci __ Fmov(h17, 3.25f); 679b8021494Sopenharmony_ci __ Fmov(h18, 2.0f); 680b8021494Sopenharmony_ci __ Fmov(h19, 0.0f); 681b8021494Sopenharmony_ci __ Fmov(h20, -2.0f); 682b8021494Sopenharmony_ci 683b8021494Sopenharmony_ci __ Fmul(h0, h17, h18); 684b8021494Sopenharmony_ci __ Fmul(h1, h18, h19); 685b8021494Sopenharmony_ci __ Fmul(h2, h14, h14); 686b8021494Sopenharmony_ci __ Fmul(h3, h15, h20); 687b8021494Sopenharmony_ci __ Fmul(h4, h16, h20); 688b8021494Sopenharmony_ci __ Fmul(h5, h15, h19); 689b8021494Sopenharmony_ci __ Fmul(h6, h19, h16); 690b8021494Sopenharmony_ci END(); 691b8021494Sopenharmony_ci 692b8021494Sopenharmony_ci if (CAN_RUN()) { 693b8021494Sopenharmony_ci RUN(); 694b8021494Sopenharmony_ci 695b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(6.5), h0); 696b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(0.0), h1); 697b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(0.0), h2); 698b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16NegativeInfinity, h3); 699b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16PositiveInfinity, h4); 700b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h5); 701b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h6); 702b8021494Sopenharmony_ci } 703b8021494Sopenharmony_ci} 704b8021494Sopenharmony_ci 705b8021494Sopenharmony_ci 706b8021494Sopenharmony_ciTEST(fnmul_h) { 707b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 708b8021494Sopenharmony_ci 709b8021494Sopenharmony_ci START(); 710b8021494Sopenharmony_ci __ Fmov(h14, -0.0f); 711b8021494Sopenharmony_ci __ Fmov(h15, kFP16PositiveInfinity); 712b8021494Sopenharmony_ci __ Fmov(h16, kFP16NegativeInfinity); 713b8021494Sopenharmony_ci __ Fmov(h17, 3.25f); 714b8021494Sopenharmony_ci __ Fmov(h18, 2.0f); 715b8021494Sopenharmony_ci __ Fmov(h19, 0.0f); 716b8021494Sopenharmony_ci __ Fmov(h20, -2.0f); 717b8021494Sopenharmony_ci 718b8021494Sopenharmony_ci __ Fnmul(h0, h17, h18); 719b8021494Sopenharmony_ci __ Fnmul(h1, h18, h19); 720b8021494Sopenharmony_ci __ Fnmul(h2, h14, h14); 721b8021494Sopenharmony_ci __ Fnmul(h3, h15, h20); 722b8021494Sopenharmony_ci __ Fnmul(h4, h16, h20); 723b8021494Sopenharmony_ci __ Fnmul(h5, h15, h19); 724b8021494Sopenharmony_ci __ Fnmul(h6, h19, h16); 725b8021494Sopenharmony_ci END(); 726b8021494Sopenharmony_ci 727b8021494Sopenharmony_ci if (CAN_RUN()) { 728b8021494Sopenharmony_ci RUN(); 729b8021494Sopenharmony_ci 730b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(-6.5), h0); 731b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(-0.0), h1); 732b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(-0.0), h2); 733b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16PositiveInfinity, h3); 734b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16NegativeInfinity, h4); 735b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0xfe00), h5); 736b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(RawbitsToFloat16(0xfe00), h6); 737b8021494Sopenharmony_ci } 738b8021494Sopenharmony_ci} 739b8021494Sopenharmony_ci 740b8021494Sopenharmony_ci 741b8021494Sopenharmony_cistatic void FmaddFmsubHelper(double n, 742b8021494Sopenharmony_ci double m, 743b8021494Sopenharmony_ci double a, 744b8021494Sopenharmony_ci double fmadd, 745b8021494Sopenharmony_ci double fmsub, 746b8021494Sopenharmony_ci double fnmadd, 747b8021494Sopenharmony_ci double fnmsub) { 748b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 749b8021494Sopenharmony_ci 750b8021494Sopenharmony_ci START(); 751b8021494Sopenharmony_ci 752b8021494Sopenharmony_ci __ Fmov(d0, n); 753b8021494Sopenharmony_ci __ Fmov(d1, m); 754b8021494Sopenharmony_ci __ Fmov(d2, a); 755b8021494Sopenharmony_ci __ Fmadd(d28, d0, d1, d2); 756b8021494Sopenharmony_ci __ Fmsub(d29, d0, d1, d2); 757b8021494Sopenharmony_ci __ Fnmadd(d30, d0, d1, d2); 758b8021494Sopenharmony_ci __ Fnmsub(d31, d0, d1, d2); 759b8021494Sopenharmony_ci 760b8021494Sopenharmony_ci END(); 761b8021494Sopenharmony_ci if (CAN_RUN()) { 762b8021494Sopenharmony_ci RUN(); 763b8021494Sopenharmony_ci 764b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(fmadd, d28); 765b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(fmsub, d29); 766b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(fnmadd, d30); 767b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(fnmsub, d31); 768b8021494Sopenharmony_ci } 769b8021494Sopenharmony_ci} 770b8021494Sopenharmony_ci 771b8021494Sopenharmony_ci 772b8021494Sopenharmony_ciTEST(fmadd_fmsub_double) { 773b8021494Sopenharmony_ci // It's hard to check the result of fused operations because the only way to 774b8021494Sopenharmony_ci // calculate the result is using fma, which is what the Simulator uses anyway. 775b8021494Sopenharmony_ci 776b8021494Sopenharmony_ci // Basic operation. 777b8021494Sopenharmony_ci FmaddFmsubHelper(1.0, 2.0, 3.0, 5.0, 1.0, -5.0, -1.0); 778b8021494Sopenharmony_ci FmaddFmsubHelper(-1.0, 2.0, 3.0, 1.0, 5.0, -1.0, -5.0); 779b8021494Sopenharmony_ci 780b8021494Sopenharmony_ci // Check the sign of exact zeroes. 781b8021494Sopenharmony_ci // n m a fmadd fmsub fnmadd fnmsub 782b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0, +0.0, -0.0, -0.0, +0.0, +0.0, +0.0); 783b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0, +0.0, -0.0, +0.0, -0.0, +0.0, +0.0); 784b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0, +0.0, +0.0, +0.0, +0.0, -0.0, +0.0); 785b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0, +0.0, +0.0, +0.0, +0.0, +0.0, -0.0); 786b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0, -0.0, -0.0, -0.0, +0.0, +0.0, +0.0); 787b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0, -0.0, -0.0, +0.0, -0.0, +0.0, +0.0); 788b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0, -0.0, +0.0, +0.0, +0.0, -0.0, +0.0); 789b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0, -0.0, +0.0, +0.0, +0.0, +0.0, -0.0); 790b8021494Sopenharmony_ci 791b8021494Sopenharmony_ci // Check NaN generation. 792b8021494Sopenharmony_ci FmaddFmsubHelper(kFP64PositiveInfinity, 793b8021494Sopenharmony_ci 0.0, 794b8021494Sopenharmony_ci 42.0, 795b8021494Sopenharmony_ci kFP64DefaultNaN, 796b8021494Sopenharmony_ci kFP64DefaultNaN, 797b8021494Sopenharmony_ci kFP64DefaultNaN, 798b8021494Sopenharmony_ci kFP64DefaultNaN); 799b8021494Sopenharmony_ci FmaddFmsubHelper(0.0, 800b8021494Sopenharmony_ci kFP64PositiveInfinity, 801b8021494Sopenharmony_ci 42.0, 802b8021494Sopenharmony_ci kFP64DefaultNaN, 803b8021494Sopenharmony_ci kFP64DefaultNaN, 804b8021494Sopenharmony_ci kFP64DefaultNaN, 805b8021494Sopenharmony_ci kFP64DefaultNaN); 806b8021494Sopenharmony_ci FmaddFmsubHelper(kFP64PositiveInfinity, 807b8021494Sopenharmony_ci 1.0, 808b8021494Sopenharmony_ci kFP64PositiveInfinity, 809b8021494Sopenharmony_ci kFP64PositiveInfinity, // inf + ( inf * 1) = inf 810b8021494Sopenharmony_ci kFP64DefaultNaN, // inf + (-inf * 1) = NaN 811b8021494Sopenharmony_ci kFP64NegativeInfinity, // -inf + (-inf * 1) = -inf 812b8021494Sopenharmony_ci kFP64DefaultNaN); // -inf + ( inf * 1) = NaN 813b8021494Sopenharmony_ci FmaddFmsubHelper(kFP64NegativeInfinity, 814b8021494Sopenharmony_ci 1.0, 815b8021494Sopenharmony_ci kFP64PositiveInfinity, 816b8021494Sopenharmony_ci kFP64DefaultNaN, // inf + (-inf * 1) = NaN 817b8021494Sopenharmony_ci kFP64PositiveInfinity, // inf + ( inf * 1) = inf 818b8021494Sopenharmony_ci kFP64DefaultNaN, // -inf + ( inf * 1) = NaN 819b8021494Sopenharmony_ci kFP64NegativeInfinity); // -inf + (-inf * 1) = -inf 820b8021494Sopenharmony_ci} 821b8021494Sopenharmony_ci 822b8021494Sopenharmony_ci 823b8021494Sopenharmony_cistatic void FmaddFmsubHelper(float n, 824b8021494Sopenharmony_ci float m, 825b8021494Sopenharmony_ci float a, 826b8021494Sopenharmony_ci float fmadd, 827b8021494Sopenharmony_ci float fmsub, 828b8021494Sopenharmony_ci float fnmadd, 829b8021494Sopenharmony_ci float fnmsub) { 830b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 831b8021494Sopenharmony_ci 832b8021494Sopenharmony_ci START(); 833b8021494Sopenharmony_ci 834b8021494Sopenharmony_ci __ Fmov(s0, n); 835b8021494Sopenharmony_ci __ Fmov(s1, m); 836b8021494Sopenharmony_ci __ Fmov(s2, a); 837b8021494Sopenharmony_ci __ Fmadd(s28, s0, s1, s2); 838b8021494Sopenharmony_ci __ Fmsub(s29, s0, s1, s2); 839b8021494Sopenharmony_ci __ Fnmadd(s30, s0, s1, s2); 840b8021494Sopenharmony_ci __ Fnmsub(s31, s0, s1, s2); 841b8021494Sopenharmony_ci 842b8021494Sopenharmony_ci END(); 843b8021494Sopenharmony_ci if (CAN_RUN()) { 844b8021494Sopenharmony_ci RUN(); 845b8021494Sopenharmony_ci 846b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(fmadd, s28); 847b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(fmsub, s29); 848b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(fnmadd, s30); 849b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(fnmsub, s31); 850b8021494Sopenharmony_ci } 851b8021494Sopenharmony_ci} 852b8021494Sopenharmony_ci 853b8021494Sopenharmony_ci 854b8021494Sopenharmony_ciTEST(fmadd_fmsub_float) { 855b8021494Sopenharmony_ci // It's hard to check the result of fused operations because the only way to 856b8021494Sopenharmony_ci // calculate the result is using fma, which is what the simulator uses anyway. 857b8021494Sopenharmony_ci 858b8021494Sopenharmony_ci // Basic operation. 859b8021494Sopenharmony_ci FmaddFmsubHelper(1.0f, 2.0f, 3.0f, 5.0f, 1.0f, -5.0f, -1.0f); 860b8021494Sopenharmony_ci FmaddFmsubHelper(-1.0f, 2.0f, 3.0f, 1.0f, 5.0f, -1.0f, -5.0f); 861b8021494Sopenharmony_ci 862b8021494Sopenharmony_ci // Check the sign of exact zeroes. 863b8021494Sopenharmony_ci // n m a fmadd fmsub fnmadd fnmsub 864b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0f, +0.0f, -0.0f, -0.0f, +0.0f, +0.0f, +0.0f); 865b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0f, +0.0f, -0.0f, +0.0f, -0.0f, +0.0f, +0.0f); 866b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0f, +0.0f, +0.0f, +0.0f, +0.0f, -0.0f, +0.0f); 867b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0f, +0.0f, +0.0f, +0.0f, +0.0f, +0.0f, -0.0f); 868b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0f, -0.0f, -0.0f, -0.0f, +0.0f, +0.0f, +0.0f); 869b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0f, -0.0f, -0.0f, +0.0f, -0.0f, +0.0f, +0.0f); 870b8021494Sopenharmony_ci FmaddFmsubHelper(-0.0f, -0.0f, +0.0f, +0.0f, +0.0f, -0.0f, +0.0f); 871b8021494Sopenharmony_ci FmaddFmsubHelper(+0.0f, -0.0f, +0.0f, +0.0f, +0.0f, +0.0f, -0.0f); 872b8021494Sopenharmony_ci 873b8021494Sopenharmony_ci // Check NaN generation. 874b8021494Sopenharmony_ci FmaddFmsubHelper(kFP32PositiveInfinity, 875b8021494Sopenharmony_ci 0.0f, 876b8021494Sopenharmony_ci 42.0f, 877b8021494Sopenharmony_ci kFP32DefaultNaN, 878b8021494Sopenharmony_ci kFP32DefaultNaN, 879b8021494Sopenharmony_ci kFP32DefaultNaN, 880b8021494Sopenharmony_ci kFP32DefaultNaN); 881b8021494Sopenharmony_ci FmaddFmsubHelper(0.0f, 882b8021494Sopenharmony_ci kFP32PositiveInfinity, 883b8021494Sopenharmony_ci 42.0f, 884b8021494Sopenharmony_ci kFP32DefaultNaN, 885b8021494Sopenharmony_ci kFP32DefaultNaN, 886b8021494Sopenharmony_ci kFP32DefaultNaN, 887b8021494Sopenharmony_ci kFP32DefaultNaN); 888b8021494Sopenharmony_ci FmaddFmsubHelper(kFP32PositiveInfinity, 889b8021494Sopenharmony_ci 1.0f, 890b8021494Sopenharmony_ci kFP32PositiveInfinity, 891b8021494Sopenharmony_ci kFP32PositiveInfinity, // inf + ( inf * 1) = inf 892b8021494Sopenharmony_ci kFP32DefaultNaN, // inf + (-inf * 1) = NaN 893b8021494Sopenharmony_ci kFP32NegativeInfinity, // -inf + (-inf * 1) = -inf 894b8021494Sopenharmony_ci kFP32DefaultNaN); // -inf + ( inf * 1) = NaN 895b8021494Sopenharmony_ci FmaddFmsubHelper(kFP32NegativeInfinity, 896b8021494Sopenharmony_ci 1.0f, 897b8021494Sopenharmony_ci kFP32PositiveInfinity, 898b8021494Sopenharmony_ci kFP32DefaultNaN, // inf + (-inf * 1) = NaN 899b8021494Sopenharmony_ci kFP32PositiveInfinity, // inf + ( inf * 1) = inf 900b8021494Sopenharmony_ci kFP32DefaultNaN, // -inf + ( inf * 1) = NaN 901b8021494Sopenharmony_ci kFP32NegativeInfinity); // -inf + (-inf * 1) = -inf 902b8021494Sopenharmony_ci} 903b8021494Sopenharmony_ci 904b8021494Sopenharmony_ci 905b8021494Sopenharmony_ciTEST(fmadd_fmsub_double_nans) { 906b8021494Sopenharmony_ci // Make sure that NaN propagation works correctly. 907b8021494Sopenharmony_ci double sig1 = RawbitsToDouble(0x7ff5555511111111); 908b8021494Sopenharmony_ci double sig2 = RawbitsToDouble(0x7ff5555522222222); 909b8021494Sopenharmony_ci double siga = RawbitsToDouble(0x7ff55555aaaaaaaa); 910b8021494Sopenharmony_ci double qui1 = RawbitsToDouble(0x7ffaaaaa11111111); 911b8021494Sopenharmony_ci double qui2 = RawbitsToDouble(0x7ffaaaaa22222222); 912b8021494Sopenharmony_ci double quia = RawbitsToDouble(0x7ffaaaaaaaaaaaaa); 913b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sig1)); 914b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sig2)); 915b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(siga)); 916b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui1)); 917b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui2)); 918b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(quia)); 919b8021494Sopenharmony_ci 920b8021494Sopenharmony_ci // The input NaNs after passing through ProcessNaN. 921b8021494Sopenharmony_ci double sig1_proc = RawbitsToDouble(0x7ffd555511111111); 922b8021494Sopenharmony_ci double sig2_proc = RawbitsToDouble(0x7ffd555522222222); 923b8021494Sopenharmony_ci double siga_proc = RawbitsToDouble(0x7ffd5555aaaaaaaa); 924b8021494Sopenharmony_ci double qui1_proc = qui1; 925b8021494Sopenharmony_ci double qui2_proc = qui2; 926b8021494Sopenharmony_ci double quia_proc = quia; 927b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sig1_proc)); 928b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sig2_proc)); 929b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(siga_proc)); 930b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui1_proc)); 931b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui2_proc)); 932b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(quia_proc)); 933b8021494Sopenharmony_ci 934b8021494Sopenharmony_ci // Negated NaNs as it would be done on ARMv8 hardware. 935b8021494Sopenharmony_ci double sig1_proc_neg = RawbitsToDouble(0xfffd555511111111); 936b8021494Sopenharmony_ci double siga_proc_neg = RawbitsToDouble(0xfffd5555aaaaaaaa); 937b8021494Sopenharmony_ci double qui1_proc_neg = RawbitsToDouble(0xfffaaaaa11111111); 938b8021494Sopenharmony_ci double quia_proc_neg = RawbitsToDouble(0xfffaaaaaaaaaaaaa); 939b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sig1_proc_neg)); 940b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(siga_proc_neg)); 941b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui1_proc_neg)); 942b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(quia_proc_neg)); 943b8021494Sopenharmony_ci 944b8021494Sopenharmony_ci // Quiet NaNs are propagated. 945b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 946b8021494Sopenharmony_ci 0, 947b8021494Sopenharmony_ci 0, 948b8021494Sopenharmony_ci qui1_proc, 949b8021494Sopenharmony_ci qui1_proc_neg, 950b8021494Sopenharmony_ci qui1_proc_neg, 951b8021494Sopenharmony_ci qui1_proc); 952b8021494Sopenharmony_ci FmaddFmsubHelper(0, qui2, 0, qui2_proc, qui2_proc, qui2_proc, qui2_proc); 953b8021494Sopenharmony_ci FmaddFmsubHelper(0, 954b8021494Sopenharmony_ci 0, 955b8021494Sopenharmony_ci quia, 956b8021494Sopenharmony_ci quia_proc, 957b8021494Sopenharmony_ci quia_proc, 958b8021494Sopenharmony_ci quia_proc_neg, 959b8021494Sopenharmony_ci quia_proc_neg); 960b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 961b8021494Sopenharmony_ci qui2, 962b8021494Sopenharmony_ci 0, 963b8021494Sopenharmony_ci qui1_proc, 964b8021494Sopenharmony_ci qui1_proc_neg, 965b8021494Sopenharmony_ci qui1_proc_neg, 966b8021494Sopenharmony_ci qui1_proc); 967b8021494Sopenharmony_ci FmaddFmsubHelper(0, 968b8021494Sopenharmony_ci qui2, 969b8021494Sopenharmony_ci quia, 970b8021494Sopenharmony_ci quia_proc, 971b8021494Sopenharmony_ci quia_proc, 972b8021494Sopenharmony_ci quia_proc_neg, 973b8021494Sopenharmony_ci quia_proc_neg); 974b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 975b8021494Sopenharmony_ci 0, 976b8021494Sopenharmony_ci quia, 977b8021494Sopenharmony_ci quia_proc, 978b8021494Sopenharmony_ci quia_proc, 979b8021494Sopenharmony_ci quia_proc_neg, 980b8021494Sopenharmony_ci quia_proc_neg); 981b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 982b8021494Sopenharmony_ci qui2, 983b8021494Sopenharmony_ci quia, 984b8021494Sopenharmony_ci quia_proc, 985b8021494Sopenharmony_ci quia_proc, 986b8021494Sopenharmony_ci quia_proc_neg, 987b8021494Sopenharmony_ci quia_proc_neg); 988b8021494Sopenharmony_ci 989b8021494Sopenharmony_ci // Signalling NaNs are propagated, and made quiet. 990b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 991b8021494Sopenharmony_ci 0, 992b8021494Sopenharmony_ci 0, 993b8021494Sopenharmony_ci sig1_proc, 994b8021494Sopenharmony_ci sig1_proc_neg, 995b8021494Sopenharmony_ci sig1_proc_neg, 996b8021494Sopenharmony_ci sig1_proc); 997b8021494Sopenharmony_ci FmaddFmsubHelper(0, sig2, 0, sig2_proc, sig2_proc, sig2_proc, sig2_proc); 998b8021494Sopenharmony_ci FmaddFmsubHelper(0, 999b8021494Sopenharmony_ci 0, 1000b8021494Sopenharmony_ci siga, 1001b8021494Sopenharmony_ci siga_proc, 1002b8021494Sopenharmony_ci siga_proc, 1003b8021494Sopenharmony_ci siga_proc_neg, 1004b8021494Sopenharmony_ci siga_proc_neg); 1005b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1006b8021494Sopenharmony_ci sig2, 1007b8021494Sopenharmony_ci 0, 1008b8021494Sopenharmony_ci sig1_proc, 1009b8021494Sopenharmony_ci sig1_proc_neg, 1010b8021494Sopenharmony_ci sig1_proc_neg, 1011b8021494Sopenharmony_ci sig1_proc); 1012b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1013b8021494Sopenharmony_ci sig2, 1014b8021494Sopenharmony_ci siga, 1015b8021494Sopenharmony_ci siga_proc, 1016b8021494Sopenharmony_ci siga_proc, 1017b8021494Sopenharmony_ci siga_proc_neg, 1018b8021494Sopenharmony_ci siga_proc_neg); 1019b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1020b8021494Sopenharmony_ci 0, 1021b8021494Sopenharmony_ci siga, 1022b8021494Sopenharmony_ci siga_proc, 1023b8021494Sopenharmony_ci siga_proc, 1024b8021494Sopenharmony_ci siga_proc_neg, 1025b8021494Sopenharmony_ci siga_proc_neg); 1026b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1027b8021494Sopenharmony_ci sig2, 1028b8021494Sopenharmony_ci siga, 1029b8021494Sopenharmony_ci siga_proc, 1030b8021494Sopenharmony_ci siga_proc, 1031b8021494Sopenharmony_ci siga_proc_neg, 1032b8021494Sopenharmony_ci siga_proc_neg); 1033b8021494Sopenharmony_ci 1034b8021494Sopenharmony_ci // Signalling NaNs take precedence over quiet NaNs. 1035b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1036b8021494Sopenharmony_ci qui2, 1037b8021494Sopenharmony_ci quia, 1038b8021494Sopenharmony_ci sig1_proc, 1039b8021494Sopenharmony_ci sig1_proc_neg, 1040b8021494Sopenharmony_ci sig1_proc_neg, 1041b8021494Sopenharmony_ci sig1_proc); 1042b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1043b8021494Sopenharmony_ci sig2, 1044b8021494Sopenharmony_ci quia, 1045b8021494Sopenharmony_ci sig2_proc, 1046b8021494Sopenharmony_ci sig2_proc, 1047b8021494Sopenharmony_ci sig2_proc, 1048b8021494Sopenharmony_ci sig2_proc); 1049b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1050b8021494Sopenharmony_ci qui2, 1051b8021494Sopenharmony_ci siga, 1052b8021494Sopenharmony_ci siga_proc, 1053b8021494Sopenharmony_ci siga_proc, 1054b8021494Sopenharmony_ci siga_proc_neg, 1055b8021494Sopenharmony_ci siga_proc_neg); 1056b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1057b8021494Sopenharmony_ci sig2, 1058b8021494Sopenharmony_ci quia, 1059b8021494Sopenharmony_ci sig1_proc, 1060b8021494Sopenharmony_ci sig1_proc_neg, 1061b8021494Sopenharmony_ci sig1_proc_neg, 1062b8021494Sopenharmony_ci sig1_proc); 1063b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1064b8021494Sopenharmony_ci sig2, 1065b8021494Sopenharmony_ci siga, 1066b8021494Sopenharmony_ci siga_proc, 1067b8021494Sopenharmony_ci siga_proc, 1068b8021494Sopenharmony_ci siga_proc_neg, 1069b8021494Sopenharmony_ci siga_proc_neg); 1070b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1071b8021494Sopenharmony_ci qui2, 1072b8021494Sopenharmony_ci siga, 1073b8021494Sopenharmony_ci siga_proc, 1074b8021494Sopenharmony_ci siga_proc, 1075b8021494Sopenharmony_ci siga_proc_neg, 1076b8021494Sopenharmony_ci siga_proc_neg); 1077b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1078b8021494Sopenharmony_ci sig2, 1079b8021494Sopenharmony_ci siga, 1080b8021494Sopenharmony_ci siga_proc, 1081b8021494Sopenharmony_ci siga_proc, 1082b8021494Sopenharmony_ci siga_proc_neg, 1083b8021494Sopenharmony_ci siga_proc_neg); 1084b8021494Sopenharmony_ci 1085b8021494Sopenharmony_ci // A NaN generated by the intermediate op1 * op2 overrides a quiet NaN in a. 1086b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1087b8021494Sopenharmony_ci kFP64PositiveInfinity, 1088b8021494Sopenharmony_ci quia, 1089b8021494Sopenharmony_ci kFP64DefaultNaN, 1090b8021494Sopenharmony_ci kFP64DefaultNaN, 1091b8021494Sopenharmony_ci kFP64DefaultNaN, 1092b8021494Sopenharmony_ci kFP64DefaultNaN); 1093b8021494Sopenharmony_ci FmaddFmsubHelper(kFP64PositiveInfinity, 1094b8021494Sopenharmony_ci 0, 1095b8021494Sopenharmony_ci quia, 1096b8021494Sopenharmony_ci kFP64DefaultNaN, 1097b8021494Sopenharmony_ci kFP64DefaultNaN, 1098b8021494Sopenharmony_ci kFP64DefaultNaN, 1099b8021494Sopenharmony_ci kFP64DefaultNaN); 1100b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1101b8021494Sopenharmony_ci kFP64NegativeInfinity, 1102b8021494Sopenharmony_ci quia, 1103b8021494Sopenharmony_ci kFP64DefaultNaN, 1104b8021494Sopenharmony_ci kFP64DefaultNaN, 1105b8021494Sopenharmony_ci kFP64DefaultNaN, 1106b8021494Sopenharmony_ci kFP64DefaultNaN); 1107b8021494Sopenharmony_ci FmaddFmsubHelper(kFP64NegativeInfinity, 1108b8021494Sopenharmony_ci 0, 1109b8021494Sopenharmony_ci quia, 1110b8021494Sopenharmony_ci kFP64DefaultNaN, 1111b8021494Sopenharmony_ci kFP64DefaultNaN, 1112b8021494Sopenharmony_ci kFP64DefaultNaN, 1113b8021494Sopenharmony_ci kFP64DefaultNaN); 1114b8021494Sopenharmony_ci} 1115b8021494Sopenharmony_ci 1116b8021494Sopenharmony_ci 1117b8021494Sopenharmony_ciTEST(fmadd_fmsub_float_nans) { 1118b8021494Sopenharmony_ci // Make sure that NaN propagation works correctly. 1119b8021494Sopenharmony_ci float sig1 = RawbitsToFloat(0x7f951111); 1120b8021494Sopenharmony_ci float sig2 = RawbitsToFloat(0x7f952222); 1121b8021494Sopenharmony_ci float siga = RawbitsToFloat(0x7f95aaaa); 1122b8021494Sopenharmony_ci float qui1 = RawbitsToFloat(0x7fea1111); 1123b8021494Sopenharmony_ci float qui2 = RawbitsToFloat(0x7fea2222); 1124b8021494Sopenharmony_ci float quia = RawbitsToFloat(0x7feaaaaa); 1125b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sig1)); 1126b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sig2)); 1127b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(siga)); 1128b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui1)); 1129b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui2)); 1130b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(quia)); 1131b8021494Sopenharmony_ci 1132b8021494Sopenharmony_ci // The input NaNs after passing through ProcessNaN. 1133b8021494Sopenharmony_ci float sig1_proc = RawbitsToFloat(0x7fd51111); 1134b8021494Sopenharmony_ci float sig2_proc = RawbitsToFloat(0x7fd52222); 1135b8021494Sopenharmony_ci float siga_proc = RawbitsToFloat(0x7fd5aaaa); 1136b8021494Sopenharmony_ci float qui1_proc = qui1; 1137b8021494Sopenharmony_ci float qui2_proc = qui2; 1138b8021494Sopenharmony_ci float quia_proc = quia; 1139b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sig1_proc)); 1140b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sig2_proc)); 1141b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(siga_proc)); 1142b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui1_proc)); 1143b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui2_proc)); 1144b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(quia_proc)); 1145b8021494Sopenharmony_ci 1146b8021494Sopenharmony_ci // Negated NaNs as it would be done on ARMv8 hardware. 1147b8021494Sopenharmony_ci float sig1_proc_neg = RawbitsToFloat(0xffd51111); 1148b8021494Sopenharmony_ci float siga_proc_neg = RawbitsToFloat(0xffd5aaaa); 1149b8021494Sopenharmony_ci float qui1_proc_neg = RawbitsToFloat(0xffea1111); 1150b8021494Sopenharmony_ci float quia_proc_neg = RawbitsToFloat(0xffeaaaaa); 1151b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sig1_proc_neg)); 1152b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(siga_proc_neg)); 1153b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qui1_proc_neg)); 1154b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(quia_proc_neg)); 1155b8021494Sopenharmony_ci 1156b8021494Sopenharmony_ci // Quiet NaNs are propagated. 1157b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1158b8021494Sopenharmony_ci 0, 1159b8021494Sopenharmony_ci 0, 1160b8021494Sopenharmony_ci qui1_proc, 1161b8021494Sopenharmony_ci qui1_proc_neg, 1162b8021494Sopenharmony_ci qui1_proc_neg, 1163b8021494Sopenharmony_ci qui1_proc); 1164b8021494Sopenharmony_ci FmaddFmsubHelper(0, qui2, 0, qui2_proc, qui2_proc, qui2_proc, qui2_proc); 1165b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1166b8021494Sopenharmony_ci 0, 1167b8021494Sopenharmony_ci quia, 1168b8021494Sopenharmony_ci quia_proc, 1169b8021494Sopenharmony_ci quia_proc, 1170b8021494Sopenharmony_ci quia_proc_neg, 1171b8021494Sopenharmony_ci quia_proc_neg); 1172b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1173b8021494Sopenharmony_ci qui2, 1174b8021494Sopenharmony_ci 0, 1175b8021494Sopenharmony_ci qui1_proc, 1176b8021494Sopenharmony_ci qui1_proc_neg, 1177b8021494Sopenharmony_ci qui1_proc_neg, 1178b8021494Sopenharmony_ci qui1_proc); 1179b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1180b8021494Sopenharmony_ci qui2, 1181b8021494Sopenharmony_ci quia, 1182b8021494Sopenharmony_ci quia_proc, 1183b8021494Sopenharmony_ci quia_proc, 1184b8021494Sopenharmony_ci quia_proc_neg, 1185b8021494Sopenharmony_ci quia_proc_neg); 1186b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1187b8021494Sopenharmony_ci 0, 1188b8021494Sopenharmony_ci quia, 1189b8021494Sopenharmony_ci quia_proc, 1190b8021494Sopenharmony_ci quia_proc, 1191b8021494Sopenharmony_ci quia_proc_neg, 1192b8021494Sopenharmony_ci quia_proc_neg); 1193b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1194b8021494Sopenharmony_ci qui2, 1195b8021494Sopenharmony_ci quia, 1196b8021494Sopenharmony_ci quia_proc, 1197b8021494Sopenharmony_ci quia_proc, 1198b8021494Sopenharmony_ci quia_proc_neg, 1199b8021494Sopenharmony_ci quia_proc_neg); 1200b8021494Sopenharmony_ci 1201b8021494Sopenharmony_ci // Signalling NaNs are propagated, and made quiet. 1202b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1203b8021494Sopenharmony_ci 0, 1204b8021494Sopenharmony_ci 0, 1205b8021494Sopenharmony_ci sig1_proc, 1206b8021494Sopenharmony_ci sig1_proc_neg, 1207b8021494Sopenharmony_ci sig1_proc_neg, 1208b8021494Sopenharmony_ci sig1_proc); 1209b8021494Sopenharmony_ci FmaddFmsubHelper(0, sig2, 0, sig2_proc, sig2_proc, sig2_proc, sig2_proc); 1210b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1211b8021494Sopenharmony_ci 0, 1212b8021494Sopenharmony_ci siga, 1213b8021494Sopenharmony_ci siga_proc, 1214b8021494Sopenharmony_ci siga_proc, 1215b8021494Sopenharmony_ci siga_proc_neg, 1216b8021494Sopenharmony_ci siga_proc_neg); 1217b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1218b8021494Sopenharmony_ci sig2, 1219b8021494Sopenharmony_ci 0, 1220b8021494Sopenharmony_ci sig1_proc, 1221b8021494Sopenharmony_ci sig1_proc_neg, 1222b8021494Sopenharmony_ci sig1_proc_neg, 1223b8021494Sopenharmony_ci sig1_proc); 1224b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1225b8021494Sopenharmony_ci sig2, 1226b8021494Sopenharmony_ci siga, 1227b8021494Sopenharmony_ci siga_proc, 1228b8021494Sopenharmony_ci siga_proc, 1229b8021494Sopenharmony_ci siga_proc_neg, 1230b8021494Sopenharmony_ci siga_proc_neg); 1231b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1232b8021494Sopenharmony_ci 0, 1233b8021494Sopenharmony_ci siga, 1234b8021494Sopenharmony_ci siga_proc, 1235b8021494Sopenharmony_ci siga_proc, 1236b8021494Sopenharmony_ci siga_proc_neg, 1237b8021494Sopenharmony_ci siga_proc_neg); 1238b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1239b8021494Sopenharmony_ci sig2, 1240b8021494Sopenharmony_ci siga, 1241b8021494Sopenharmony_ci siga_proc, 1242b8021494Sopenharmony_ci siga_proc, 1243b8021494Sopenharmony_ci siga_proc_neg, 1244b8021494Sopenharmony_ci siga_proc_neg); 1245b8021494Sopenharmony_ci 1246b8021494Sopenharmony_ci // Signalling NaNs take precedence over quiet NaNs. 1247b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1248b8021494Sopenharmony_ci qui2, 1249b8021494Sopenharmony_ci quia, 1250b8021494Sopenharmony_ci sig1_proc, 1251b8021494Sopenharmony_ci sig1_proc_neg, 1252b8021494Sopenharmony_ci sig1_proc_neg, 1253b8021494Sopenharmony_ci sig1_proc); 1254b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1255b8021494Sopenharmony_ci sig2, 1256b8021494Sopenharmony_ci quia, 1257b8021494Sopenharmony_ci sig2_proc, 1258b8021494Sopenharmony_ci sig2_proc, 1259b8021494Sopenharmony_ci sig2_proc, 1260b8021494Sopenharmony_ci sig2_proc); 1261b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1262b8021494Sopenharmony_ci qui2, 1263b8021494Sopenharmony_ci siga, 1264b8021494Sopenharmony_ci siga_proc, 1265b8021494Sopenharmony_ci siga_proc, 1266b8021494Sopenharmony_ci siga_proc_neg, 1267b8021494Sopenharmony_ci siga_proc_neg); 1268b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1269b8021494Sopenharmony_ci sig2, 1270b8021494Sopenharmony_ci quia, 1271b8021494Sopenharmony_ci sig1_proc, 1272b8021494Sopenharmony_ci sig1_proc_neg, 1273b8021494Sopenharmony_ci sig1_proc_neg, 1274b8021494Sopenharmony_ci sig1_proc); 1275b8021494Sopenharmony_ci FmaddFmsubHelper(qui1, 1276b8021494Sopenharmony_ci sig2, 1277b8021494Sopenharmony_ci siga, 1278b8021494Sopenharmony_ci siga_proc, 1279b8021494Sopenharmony_ci siga_proc, 1280b8021494Sopenharmony_ci siga_proc_neg, 1281b8021494Sopenharmony_ci siga_proc_neg); 1282b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1283b8021494Sopenharmony_ci qui2, 1284b8021494Sopenharmony_ci siga, 1285b8021494Sopenharmony_ci siga_proc, 1286b8021494Sopenharmony_ci siga_proc, 1287b8021494Sopenharmony_ci siga_proc_neg, 1288b8021494Sopenharmony_ci siga_proc_neg); 1289b8021494Sopenharmony_ci FmaddFmsubHelper(sig1, 1290b8021494Sopenharmony_ci sig2, 1291b8021494Sopenharmony_ci siga, 1292b8021494Sopenharmony_ci siga_proc, 1293b8021494Sopenharmony_ci siga_proc, 1294b8021494Sopenharmony_ci siga_proc_neg, 1295b8021494Sopenharmony_ci siga_proc_neg); 1296b8021494Sopenharmony_ci 1297b8021494Sopenharmony_ci // A NaN generated by the intermediate op1 * op2 overrides a quiet NaN in a. 1298b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1299b8021494Sopenharmony_ci kFP32PositiveInfinity, 1300b8021494Sopenharmony_ci quia, 1301b8021494Sopenharmony_ci kFP32DefaultNaN, 1302b8021494Sopenharmony_ci kFP32DefaultNaN, 1303b8021494Sopenharmony_ci kFP32DefaultNaN, 1304b8021494Sopenharmony_ci kFP32DefaultNaN); 1305b8021494Sopenharmony_ci FmaddFmsubHelper(kFP32PositiveInfinity, 1306b8021494Sopenharmony_ci 0, 1307b8021494Sopenharmony_ci quia, 1308b8021494Sopenharmony_ci kFP32DefaultNaN, 1309b8021494Sopenharmony_ci kFP32DefaultNaN, 1310b8021494Sopenharmony_ci kFP32DefaultNaN, 1311b8021494Sopenharmony_ci kFP32DefaultNaN); 1312b8021494Sopenharmony_ci FmaddFmsubHelper(0, 1313b8021494Sopenharmony_ci kFP32NegativeInfinity, 1314b8021494Sopenharmony_ci quia, 1315b8021494Sopenharmony_ci kFP32DefaultNaN, 1316b8021494Sopenharmony_ci kFP32DefaultNaN, 1317b8021494Sopenharmony_ci kFP32DefaultNaN, 1318b8021494Sopenharmony_ci kFP32DefaultNaN); 1319b8021494Sopenharmony_ci FmaddFmsubHelper(kFP32NegativeInfinity, 1320b8021494Sopenharmony_ci 0, 1321b8021494Sopenharmony_ci quia, 1322b8021494Sopenharmony_ci kFP32DefaultNaN, 1323b8021494Sopenharmony_ci kFP32DefaultNaN, 1324b8021494Sopenharmony_ci kFP32DefaultNaN, 1325b8021494Sopenharmony_ci kFP32DefaultNaN); 1326b8021494Sopenharmony_ci} 1327b8021494Sopenharmony_ci 1328b8021494Sopenharmony_ci 1329b8021494Sopenharmony_ciTEST(fdiv) { 1330b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 1331b8021494Sopenharmony_ci 1332b8021494Sopenharmony_ci START(); 1333b8021494Sopenharmony_ci __ Fmov(s14, -0.0f); 1334b8021494Sopenharmony_ci __ Fmov(s15, kFP32PositiveInfinity); 1335b8021494Sopenharmony_ci __ Fmov(s16, kFP32NegativeInfinity); 1336b8021494Sopenharmony_ci __ Fmov(s17, 3.25f); 1337b8021494Sopenharmony_ci __ Fmov(s18, 2.0f); 1338b8021494Sopenharmony_ci __ Fmov(s19, 2.0f); 1339b8021494Sopenharmony_ci __ Fmov(s20, -2.0f); 1340b8021494Sopenharmony_ci 1341b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 1342b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 1343b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 1344b8021494Sopenharmony_ci __ Fmov(d29, 0.0); 1345b8021494Sopenharmony_ci __ Fmov(d30, -2.0); 1346b8021494Sopenharmony_ci __ Fmov(d31, 2.25); 1347b8021494Sopenharmony_ci 1348b8021494Sopenharmony_ci __ Fdiv(s0, s17, s18); 1349b8021494Sopenharmony_ci __ Fdiv(s1, s18, s19); 1350b8021494Sopenharmony_ci __ Fdiv(s2, s14, s18); 1351b8021494Sopenharmony_ci __ Fdiv(s3, s18, s15); 1352b8021494Sopenharmony_ci __ Fdiv(s4, s18, s16); 1353b8021494Sopenharmony_ci __ Fdiv(s5, s15, s16); 1354b8021494Sopenharmony_ci __ Fdiv(s6, s14, s14); 1355b8021494Sopenharmony_ci 1356b8021494Sopenharmony_ci __ Fdiv(d7, d31, d30); 1357b8021494Sopenharmony_ci __ Fdiv(d8, d29, d31); 1358b8021494Sopenharmony_ci __ Fdiv(d9, d26, d31); 1359b8021494Sopenharmony_ci __ Fdiv(d10, d31, d27); 1360b8021494Sopenharmony_ci __ Fdiv(d11, d31, d28); 1361b8021494Sopenharmony_ci __ Fdiv(d12, d28, d27); 1362b8021494Sopenharmony_ci __ Fdiv(d13, d29, d29); 1363b8021494Sopenharmony_ci END(); 1364b8021494Sopenharmony_ci 1365b8021494Sopenharmony_ci if (CAN_RUN()) { 1366b8021494Sopenharmony_ci RUN(); 1367b8021494Sopenharmony_ci 1368b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.625f, s0); 1369b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0f, s1); 1370b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0f, s2); 1371b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0f, s3); 1372b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0f, s4); 1373b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s5); 1374b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s6); 1375b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.125, d7); 1376b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d8); 1377b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d9); 1378b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d10); 1379b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d11); 1380b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d12); 1381b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d13); 1382b8021494Sopenharmony_ci } 1383b8021494Sopenharmony_ci} 1384b8021494Sopenharmony_ci 1385b8021494Sopenharmony_ci 1386b8021494Sopenharmony_ciTEST(fdiv_h) { 1387b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 1388b8021494Sopenharmony_ci 1389b8021494Sopenharmony_ci START(); 1390b8021494Sopenharmony_ci __ Fmov(h14, -0.0f); 1391b8021494Sopenharmony_ci __ Fmov(h15, kFP16PositiveInfinity); 1392b8021494Sopenharmony_ci __ Fmov(h16, kFP16NegativeInfinity); 1393b8021494Sopenharmony_ci __ Fmov(h17, 3.25f); 1394b8021494Sopenharmony_ci __ Fmov(h18, 2.0f); 1395b8021494Sopenharmony_ci __ Fmov(h19, 2.0f); 1396b8021494Sopenharmony_ci __ Fmov(h20, -2.0f); 1397b8021494Sopenharmony_ci 1398b8021494Sopenharmony_ci __ Fdiv(h0, h17, h18); 1399b8021494Sopenharmony_ci __ Fdiv(h1, h18, h19); 1400b8021494Sopenharmony_ci __ Fdiv(h2, h14, h18); 1401b8021494Sopenharmony_ci __ Fdiv(h3, h18, h15); 1402b8021494Sopenharmony_ci __ Fdiv(h4, h18, h16); 1403b8021494Sopenharmony_ci __ Fdiv(h5, h15, h16); 1404b8021494Sopenharmony_ci __ Fdiv(h6, h14, h14); 1405b8021494Sopenharmony_ci END(); 1406b8021494Sopenharmony_ci 1407b8021494Sopenharmony_ci if (CAN_RUN()) { 1408b8021494Sopenharmony_ci RUN(); 1409b8021494Sopenharmony_ci 1410b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.625f), h0); 1411b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.0f), h1); 1412b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(-0.0f), h2); 1413b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(0.0f), h3); 1414b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(-0.0f), h4); 1415b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h5); 1416b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(kFP16DefaultNaN, h6); 1417b8021494Sopenharmony_ci } 1418b8021494Sopenharmony_ci} 1419b8021494Sopenharmony_ci 1420b8021494Sopenharmony_cistatic float MinMaxHelper(float n, 1421b8021494Sopenharmony_ci float m, 1422b8021494Sopenharmony_ci bool min, 1423b8021494Sopenharmony_ci float quiet_nan_substitute = 0.0) { 1424b8021494Sopenharmony_ci const uint64_t kFP32QuietNaNMask = 0x00400000; 1425b8021494Sopenharmony_ci uint32_t raw_n = FloatToRawbits(n); 1426b8021494Sopenharmony_ci uint32_t raw_m = FloatToRawbits(m); 1427b8021494Sopenharmony_ci 1428b8021494Sopenharmony_ci if (IsNaN(n) && ((raw_n & kFP32QuietNaNMask) == 0)) { 1429b8021494Sopenharmony_ci // n is signalling NaN. 1430b8021494Sopenharmony_ci return RawbitsToFloat(raw_n | kFP32QuietNaNMask); 1431b8021494Sopenharmony_ci } else if (IsNaN(m) && ((raw_m & kFP32QuietNaNMask) == 0)) { 1432b8021494Sopenharmony_ci // m is signalling NaN. 1433b8021494Sopenharmony_ci return RawbitsToFloat(raw_m | kFP32QuietNaNMask); 1434b8021494Sopenharmony_ci } else if (quiet_nan_substitute == 0.0) { 1435b8021494Sopenharmony_ci if (IsNaN(n)) { 1436b8021494Sopenharmony_ci // n is quiet NaN. 1437b8021494Sopenharmony_ci return n; 1438b8021494Sopenharmony_ci } else if (IsNaN(m)) { 1439b8021494Sopenharmony_ci // m is quiet NaN. 1440b8021494Sopenharmony_ci return m; 1441b8021494Sopenharmony_ci } 1442b8021494Sopenharmony_ci } else { 1443b8021494Sopenharmony_ci // Substitute n or m if one is quiet, but not both. 1444b8021494Sopenharmony_ci if (IsNaN(n) && !IsNaN(m)) { 1445b8021494Sopenharmony_ci // n is quiet NaN: replace with substitute. 1446b8021494Sopenharmony_ci n = quiet_nan_substitute; 1447b8021494Sopenharmony_ci } else if (!IsNaN(n) && IsNaN(m)) { 1448b8021494Sopenharmony_ci // m is quiet NaN: replace with substitute. 1449b8021494Sopenharmony_ci m = quiet_nan_substitute; 1450b8021494Sopenharmony_ci } 1451b8021494Sopenharmony_ci } 1452b8021494Sopenharmony_ci 1453b8021494Sopenharmony_ci if ((n == 0.0) && (m == 0.0) && (copysign(1.0, n) != copysign(1.0, m))) { 1454b8021494Sopenharmony_ci return min ? -0.0 : 0.0; 1455b8021494Sopenharmony_ci } 1456b8021494Sopenharmony_ci 1457b8021494Sopenharmony_ci return min ? fminf(n, m) : fmaxf(n, m); 1458b8021494Sopenharmony_ci} 1459b8021494Sopenharmony_ci 1460b8021494Sopenharmony_ci 1461b8021494Sopenharmony_cistatic double MinMaxHelper(double n, 1462b8021494Sopenharmony_ci double m, 1463b8021494Sopenharmony_ci bool min, 1464b8021494Sopenharmony_ci double quiet_nan_substitute = 0.0) { 1465b8021494Sopenharmony_ci const uint64_t kFP64QuietNaNMask = 0x0008000000000000; 1466b8021494Sopenharmony_ci uint64_t raw_n = DoubleToRawbits(n); 1467b8021494Sopenharmony_ci uint64_t raw_m = DoubleToRawbits(m); 1468b8021494Sopenharmony_ci 1469b8021494Sopenharmony_ci if (IsNaN(n) && ((raw_n & kFP64QuietNaNMask) == 0)) { 1470b8021494Sopenharmony_ci // n is signalling NaN. 1471b8021494Sopenharmony_ci return RawbitsToDouble(raw_n | kFP64QuietNaNMask); 1472b8021494Sopenharmony_ci } else if (IsNaN(m) && ((raw_m & kFP64QuietNaNMask) == 0)) { 1473b8021494Sopenharmony_ci // m is signalling NaN. 1474b8021494Sopenharmony_ci return RawbitsToDouble(raw_m | kFP64QuietNaNMask); 1475b8021494Sopenharmony_ci } else if (quiet_nan_substitute == 0.0) { 1476b8021494Sopenharmony_ci if (IsNaN(n)) { 1477b8021494Sopenharmony_ci // n is quiet NaN. 1478b8021494Sopenharmony_ci return n; 1479b8021494Sopenharmony_ci } else if (IsNaN(m)) { 1480b8021494Sopenharmony_ci // m is quiet NaN. 1481b8021494Sopenharmony_ci return m; 1482b8021494Sopenharmony_ci } 1483b8021494Sopenharmony_ci } else { 1484b8021494Sopenharmony_ci // Substitute n or m if one is quiet, but not both. 1485b8021494Sopenharmony_ci if (IsNaN(n) && !IsNaN(m)) { 1486b8021494Sopenharmony_ci // n is quiet NaN: replace with substitute. 1487b8021494Sopenharmony_ci n = quiet_nan_substitute; 1488b8021494Sopenharmony_ci } else if (!IsNaN(n) && IsNaN(m)) { 1489b8021494Sopenharmony_ci // m is quiet NaN: replace with substitute. 1490b8021494Sopenharmony_ci m = quiet_nan_substitute; 1491b8021494Sopenharmony_ci } 1492b8021494Sopenharmony_ci } 1493b8021494Sopenharmony_ci 1494b8021494Sopenharmony_ci if ((n == 0.0) && (m == 0.0) && (copysign(1.0, n) != copysign(1.0, m))) { 1495b8021494Sopenharmony_ci return min ? -0.0 : 0.0; 1496b8021494Sopenharmony_ci } 1497b8021494Sopenharmony_ci 1498b8021494Sopenharmony_ci return min ? fmin(n, m) : fmax(n, m); 1499b8021494Sopenharmony_ci} 1500b8021494Sopenharmony_ci 1501b8021494Sopenharmony_ci 1502b8021494Sopenharmony_cistatic void FminFmaxDoubleHelper( 1503b8021494Sopenharmony_ci double n, double m, double min, double max, double minnm, double maxnm) { 1504b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 1505b8021494Sopenharmony_ci 1506b8021494Sopenharmony_ci START(); 1507b8021494Sopenharmony_ci __ Fmov(d0, n); 1508b8021494Sopenharmony_ci __ Fmov(d1, m); 1509b8021494Sopenharmony_ci __ Fmin(d28, d0, d1); 1510b8021494Sopenharmony_ci __ Fmax(d29, d0, d1); 1511b8021494Sopenharmony_ci __ Fminnm(d30, d0, d1); 1512b8021494Sopenharmony_ci __ Fmaxnm(d31, d0, d1); 1513b8021494Sopenharmony_ci END(); 1514b8021494Sopenharmony_ci 1515b8021494Sopenharmony_ci if (CAN_RUN()) { 1516b8021494Sopenharmony_ci RUN(); 1517b8021494Sopenharmony_ci 1518b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(min, d28); 1519b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(max, d29); 1520b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(minnm, d30); 1521b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(maxnm, d31); 1522b8021494Sopenharmony_ci } 1523b8021494Sopenharmony_ci} 1524b8021494Sopenharmony_ci 1525b8021494Sopenharmony_ci 1526b8021494Sopenharmony_ciTEST(fmax_fmin_d) { 1527b8021494Sopenharmony_ci // Use non-standard NaNs to check that the payload bits are preserved. 1528b8021494Sopenharmony_ci double snan = RawbitsToDouble(0x7ff5555512345678); 1529b8021494Sopenharmony_ci double qnan = RawbitsToDouble(0x7ffaaaaa87654321); 1530b8021494Sopenharmony_ci 1531b8021494Sopenharmony_ci double snan_processed = RawbitsToDouble(0x7ffd555512345678); 1532b8021494Sopenharmony_ci double qnan_processed = qnan; 1533b8021494Sopenharmony_ci 1534b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(snan)); 1535b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qnan)); 1536b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(snan_processed)); 1537b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qnan_processed)); 1538b8021494Sopenharmony_ci 1539b8021494Sopenharmony_ci // Bootstrap tests. 1540b8021494Sopenharmony_ci FminFmaxDoubleHelper(0, 0, 0, 0, 0, 0); 1541b8021494Sopenharmony_ci FminFmaxDoubleHelper(0, 1, 0, 1, 0, 1); 1542b8021494Sopenharmony_ci FminFmaxDoubleHelper(kFP64PositiveInfinity, 1543b8021494Sopenharmony_ci kFP64NegativeInfinity, 1544b8021494Sopenharmony_ci kFP64NegativeInfinity, 1545b8021494Sopenharmony_ci kFP64PositiveInfinity, 1546b8021494Sopenharmony_ci kFP64NegativeInfinity, 1547b8021494Sopenharmony_ci kFP64PositiveInfinity); 1548b8021494Sopenharmony_ci FminFmaxDoubleHelper(snan, 1549b8021494Sopenharmony_ci 0, 1550b8021494Sopenharmony_ci snan_processed, 1551b8021494Sopenharmony_ci snan_processed, 1552b8021494Sopenharmony_ci snan_processed, 1553b8021494Sopenharmony_ci snan_processed); 1554b8021494Sopenharmony_ci FminFmaxDoubleHelper(0, 1555b8021494Sopenharmony_ci snan, 1556b8021494Sopenharmony_ci snan_processed, 1557b8021494Sopenharmony_ci snan_processed, 1558b8021494Sopenharmony_ci snan_processed, 1559b8021494Sopenharmony_ci snan_processed); 1560b8021494Sopenharmony_ci FminFmaxDoubleHelper(qnan, 0, qnan_processed, qnan_processed, 0, 0); 1561b8021494Sopenharmony_ci FminFmaxDoubleHelper(0, qnan, qnan_processed, qnan_processed, 0, 0); 1562b8021494Sopenharmony_ci FminFmaxDoubleHelper(qnan, 1563b8021494Sopenharmony_ci snan, 1564b8021494Sopenharmony_ci snan_processed, 1565b8021494Sopenharmony_ci snan_processed, 1566b8021494Sopenharmony_ci snan_processed, 1567b8021494Sopenharmony_ci snan_processed); 1568b8021494Sopenharmony_ci FminFmaxDoubleHelper(snan, 1569b8021494Sopenharmony_ci qnan, 1570b8021494Sopenharmony_ci snan_processed, 1571b8021494Sopenharmony_ci snan_processed, 1572b8021494Sopenharmony_ci snan_processed, 1573b8021494Sopenharmony_ci snan_processed); 1574b8021494Sopenharmony_ci 1575b8021494Sopenharmony_ci // Iterate over all combinations of inputs. 1576b8021494Sopenharmony_ci double inputs[] = {DBL_MAX, 1577b8021494Sopenharmony_ci DBL_MIN, 1578b8021494Sopenharmony_ci 1.0, 1579b8021494Sopenharmony_ci 0.0, 1580b8021494Sopenharmony_ci -DBL_MAX, 1581b8021494Sopenharmony_ci -DBL_MIN, 1582b8021494Sopenharmony_ci -1.0, 1583b8021494Sopenharmony_ci -0.0, 1584b8021494Sopenharmony_ci kFP64PositiveInfinity, 1585b8021494Sopenharmony_ci kFP64NegativeInfinity, 1586b8021494Sopenharmony_ci kFP64QuietNaN, 1587b8021494Sopenharmony_ci kFP64SignallingNaN}; 1588b8021494Sopenharmony_ci 1589b8021494Sopenharmony_ci const int count = sizeof(inputs) / sizeof(inputs[0]); 1590b8021494Sopenharmony_ci 1591b8021494Sopenharmony_ci for (int in = 0; in < count; in++) { 1592b8021494Sopenharmony_ci double n = inputs[in]; 1593b8021494Sopenharmony_ci for (int im = 0; im < count; im++) { 1594b8021494Sopenharmony_ci double m = inputs[im]; 1595b8021494Sopenharmony_ci FminFmaxDoubleHelper(n, 1596b8021494Sopenharmony_ci m, 1597b8021494Sopenharmony_ci MinMaxHelper(n, m, true), 1598b8021494Sopenharmony_ci MinMaxHelper(n, m, false), 1599b8021494Sopenharmony_ci MinMaxHelper(n, m, true, kFP64PositiveInfinity), 1600b8021494Sopenharmony_ci MinMaxHelper(n, m, false, kFP64NegativeInfinity)); 1601b8021494Sopenharmony_ci } 1602b8021494Sopenharmony_ci } 1603b8021494Sopenharmony_ci} 1604b8021494Sopenharmony_ci 1605b8021494Sopenharmony_ci 1606b8021494Sopenharmony_cistatic void FminFmaxFloatHelper( 1607b8021494Sopenharmony_ci float n, float m, float min, float max, float minnm, float maxnm) { 1608b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 1609b8021494Sopenharmony_ci 1610b8021494Sopenharmony_ci START(); 1611b8021494Sopenharmony_ci __ Fmov(s0, n); 1612b8021494Sopenharmony_ci __ Fmov(s1, m); 1613b8021494Sopenharmony_ci __ Fmin(s28, s0, s1); 1614b8021494Sopenharmony_ci __ Fmax(s29, s0, s1); 1615b8021494Sopenharmony_ci __ Fminnm(s30, s0, s1); 1616b8021494Sopenharmony_ci __ Fmaxnm(s31, s0, s1); 1617b8021494Sopenharmony_ci END(); 1618b8021494Sopenharmony_ci 1619b8021494Sopenharmony_ci if (CAN_RUN()) { 1620b8021494Sopenharmony_ci RUN(); 1621b8021494Sopenharmony_ci 1622b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(min, s28); 1623b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(max, s29); 1624b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(minnm, s30); 1625b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(maxnm, s31); 1626b8021494Sopenharmony_ci } 1627b8021494Sopenharmony_ci} 1628b8021494Sopenharmony_ci 1629b8021494Sopenharmony_ci 1630b8021494Sopenharmony_ciTEST(fmax_fmin_s) { 1631b8021494Sopenharmony_ci // Use non-standard NaNs to check that the payload bits are preserved. 1632b8021494Sopenharmony_ci float snan = RawbitsToFloat(0x7f951234); 1633b8021494Sopenharmony_ci float qnan = RawbitsToFloat(0x7fea8765); 1634b8021494Sopenharmony_ci 1635b8021494Sopenharmony_ci float snan_processed = RawbitsToFloat(0x7fd51234); 1636b8021494Sopenharmony_ci float qnan_processed = qnan; 1637b8021494Sopenharmony_ci 1638b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(snan)); 1639b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qnan)); 1640b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(snan_processed)); 1641b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qnan_processed)); 1642b8021494Sopenharmony_ci 1643b8021494Sopenharmony_ci // Bootstrap tests. 1644b8021494Sopenharmony_ci FminFmaxFloatHelper(0, 0, 0, 0, 0, 0); 1645b8021494Sopenharmony_ci FminFmaxFloatHelper(0, 1, 0, 1, 0, 1); 1646b8021494Sopenharmony_ci FminFmaxFloatHelper(kFP32PositiveInfinity, 1647b8021494Sopenharmony_ci kFP32NegativeInfinity, 1648b8021494Sopenharmony_ci kFP32NegativeInfinity, 1649b8021494Sopenharmony_ci kFP32PositiveInfinity, 1650b8021494Sopenharmony_ci kFP32NegativeInfinity, 1651b8021494Sopenharmony_ci kFP32PositiveInfinity); 1652b8021494Sopenharmony_ci FminFmaxFloatHelper(snan, 1653b8021494Sopenharmony_ci 0, 1654b8021494Sopenharmony_ci snan_processed, 1655b8021494Sopenharmony_ci snan_processed, 1656b8021494Sopenharmony_ci snan_processed, 1657b8021494Sopenharmony_ci snan_processed); 1658b8021494Sopenharmony_ci FminFmaxFloatHelper(0, 1659b8021494Sopenharmony_ci snan, 1660b8021494Sopenharmony_ci snan_processed, 1661b8021494Sopenharmony_ci snan_processed, 1662b8021494Sopenharmony_ci snan_processed, 1663b8021494Sopenharmony_ci snan_processed); 1664b8021494Sopenharmony_ci FminFmaxFloatHelper(qnan, 0, qnan_processed, qnan_processed, 0, 0); 1665b8021494Sopenharmony_ci FminFmaxFloatHelper(0, qnan, qnan_processed, qnan_processed, 0, 0); 1666b8021494Sopenharmony_ci FminFmaxFloatHelper(qnan, 1667b8021494Sopenharmony_ci snan, 1668b8021494Sopenharmony_ci snan_processed, 1669b8021494Sopenharmony_ci snan_processed, 1670b8021494Sopenharmony_ci snan_processed, 1671b8021494Sopenharmony_ci snan_processed); 1672b8021494Sopenharmony_ci FminFmaxFloatHelper(snan, 1673b8021494Sopenharmony_ci qnan, 1674b8021494Sopenharmony_ci snan_processed, 1675b8021494Sopenharmony_ci snan_processed, 1676b8021494Sopenharmony_ci snan_processed, 1677b8021494Sopenharmony_ci snan_processed); 1678b8021494Sopenharmony_ci 1679b8021494Sopenharmony_ci // Iterate over all combinations of inputs. 1680b8021494Sopenharmony_ci float inputs[] = {FLT_MAX, 1681b8021494Sopenharmony_ci FLT_MIN, 1682b8021494Sopenharmony_ci 1.0, 1683b8021494Sopenharmony_ci 0.0, 1684b8021494Sopenharmony_ci -FLT_MAX, 1685b8021494Sopenharmony_ci -FLT_MIN, 1686b8021494Sopenharmony_ci -1.0, 1687b8021494Sopenharmony_ci -0.0, 1688b8021494Sopenharmony_ci kFP32PositiveInfinity, 1689b8021494Sopenharmony_ci kFP32NegativeInfinity, 1690b8021494Sopenharmony_ci kFP32QuietNaN, 1691b8021494Sopenharmony_ci kFP32SignallingNaN}; 1692b8021494Sopenharmony_ci 1693b8021494Sopenharmony_ci const int count = sizeof(inputs) / sizeof(inputs[0]); 1694b8021494Sopenharmony_ci 1695b8021494Sopenharmony_ci for (int in = 0; in < count; in++) { 1696b8021494Sopenharmony_ci float n = inputs[in]; 1697b8021494Sopenharmony_ci for (int im = 0; im < count; im++) { 1698b8021494Sopenharmony_ci float m = inputs[im]; 1699b8021494Sopenharmony_ci FminFmaxFloatHelper(n, 1700b8021494Sopenharmony_ci m, 1701b8021494Sopenharmony_ci MinMaxHelper(n, m, true), 1702b8021494Sopenharmony_ci MinMaxHelper(n, m, false), 1703b8021494Sopenharmony_ci MinMaxHelper(n, m, true, kFP32PositiveInfinity), 1704b8021494Sopenharmony_ci MinMaxHelper(n, m, false, kFP32NegativeInfinity)); 1705b8021494Sopenharmony_ci } 1706b8021494Sopenharmony_ci } 1707b8021494Sopenharmony_ci} 1708b8021494Sopenharmony_ci 1709b8021494Sopenharmony_ciTEST(fccmp) { 1710b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 1711b8021494Sopenharmony_ci 1712b8021494Sopenharmony_ci START(); 1713b8021494Sopenharmony_ci __ Fmov(s16, 0.0); 1714b8021494Sopenharmony_ci __ Fmov(s17, 0.5); 1715b8021494Sopenharmony_ci __ Fmov(d18, -0.5); 1716b8021494Sopenharmony_ci __ Fmov(d19, -1.0); 1717b8021494Sopenharmony_ci __ Mov(x20, 0); 1718b8021494Sopenharmony_ci __ Mov(x21, 0x7ff0000000000001); // Double precision NaN. 1719b8021494Sopenharmony_ci __ Fmov(d21, x21); 1720b8021494Sopenharmony_ci __ Mov(w22, 0x7f800001); // Single precision NaN. 1721b8021494Sopenharmony_ci __ Fmov(s22, w22); 1722b8021494Sopenharmony_ci 1723b8021494Sopenharmony_ci __ Cmp(x20, 0); 1724b8021494Sopenharmony_ci __ Fccmp(s16, s16, NoFlag, eq); 1725b8021494Sopenharmony_ci __ Mrs(x0, NZCV); 1726b8021494Sopenharmony_ci 1727b8021494Sopenharmony_ci __ Cmp(x20, 0); 1728b8021494Sopenharmony_ci __ Fccmp(s16, s16, VFlag, ne); 1729b8021494Sopenharmony_ci __ Mrs(x1, NZCV); 1730b8021494Sopenharmony_ci 1731b8021494Sopenharmony_ci __ Cmp(x20, 0); 1732b8021494Sopenharmony_ci __ Fccmp(s16, s17, CFlag, ge); 1733b8021494Sopenharmony_ci __ Mrs(x2, NZCV); 1734b8021494Sopenharmony_ci 1735b8021494Sopenharmony_ci __ Cmp(x20, 0); 1736b8021494Sopenharmony_ci __ Fccmp(s16, s17, CVFlag, lt); 1737b8021494Sopenharmony_ci __ Mrs(x3, NZCV); 1738b8021494Sopenharmony_ci 1739b8021494Sopenharmony_ci __ Cmp(x20, 0); 1740b8021494Sopenharmony_ci __ Fccmp(d18, d18, ZFlag, le); 1741b8021494Sopenharmony_ci __ Mrs(x4, NZCV); 1742b8021494Sopenharmony_ci 1743b8021494Sopenharmony_ci __ Cmp(x20, 0); 1744b8021494Sopenharmony_ci __ Fccmp(d18, d18, ZVFlag, gt); 1745b8021494Sopenharmony_ci __ Mrs(x5, NZCV); 1746b8021494Sopenharmony_ci 1747b8021494Sopenharmony_ci __ Cmp(x20, 0); 1748b8021494Sopenharmony_ci __ Fccmp(d18, d19, ZCVFlag, ls); 1749b8021494Sopenharmony_ci __ Mrs(x6, NZCV); 1750b8021494Sopenharmony_ci 1751b8021494Sopenharmony_ci __ Cmp(x20, 0); 1752b8021494Sopenharmony_ci __ Fccmp(d18, d19, NFlag, hi); 1753b8021494Sopenharmony_ci __ Mrs(x7, NZCV); 1754b8021494Sopenharmony_ci 1755b8021494Sopenharmony_ci // The Macro Assembler does not allow al or nv as condition. 1756b8021494Sopenharmony_ci { 1757b8021494Sopenharmony_ci ExactAssemblyScope scope(&masm, kInstructionSize); 1758b8021494Sopenharmony_ci __ fccmp(s16, s16, NFlag, al); 1759b8021494Sopenharmony_ci } 1760b8021494Sopenharmony_ci __ Mrs(x8, NZCV); 1761b8021494Sopenharmony_ci 1762b8021494Sopenharmony_ci { 1763b8021494Sopenharmony_ci ExactAssemblyScope scope(&masm, kInstructionSize); 1764b8021494Sopenharmony_ci __ fccmp(d18, d18, NFlag, nv); 1765b8021494Sopenharmony_ci } 1766b8021494Sopenharmony_ci __ Mrs(x9, NZCV); 1767b8021494Sopenharmony_ci 1768b8021494Sopenharmony_ci __ Cmp(x20, 0); 1769b8021494Sopenharmony_ci __ Fccmpe(s16, s16, NoFlag, eq); 1770b8021494Sopenharmony_ci __ Mrs(x10, NZCV); 1771b8021494Sopenharmony_ci 1772b8021494Sopenharmony_ci __ Cmp(x20, 0); 1773b8021494Sopenharmony_ci __ Fccmpe(d18, d19, ZCVFlag, ls); 1774b8021494Sopenharmony_ci __ Mrs(x11, NZCV); 1775b8021494Sopenharmony_ci 1776b8021494Sopenharmony_ci __ Cmp(x20, 0); 1777b8021494Sopenharmony_ci __ Fccmpe(d21, d21, NoFlag, eq); 1778b8021494Sopenharmony_ci __ Mrs(x12, NZCV); 1779b8021494Sopenharmony_ci 1780b8021494Sopenharmony_ci __ Cmp(x20, 0); 1781b8021494Sopenharmony_ci __ Fccmpe(s22, s22, NoFlag, eq); 1782b8021494Sopenharmony_ci __ Mrs(x13, NZCV); 1783b8021494Sopenharmony_ci END(); 1784b8021494Sopenharmony_ci 1785b8021494Sopenharmony_ci if (CAN_RUN()) { 1786b8021494Sopenharmony_ci RUN(); 1787b8021494Sopenharmony_ci 1788b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w0); 1789b8021494Sopenharmony_ci ASSERT_EQUAL_32(VFlag, w1); 1790b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w2); 1791b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w3); 1792b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w4); 1793b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZVFlag, w5); 1794b8021494Sopenharmony_ci ASSERT_EQUAL_32(CFlag, w6); 1795b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w7); 1796b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w8); 1797b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w9); 1798b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w10); 1799b8021494Sopenharmony_ci ASSERT_EQUAL_32(CFlag, w11); 1800b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w12); 1801b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w13); 1802b8021494Sopenharmony_ci } 1803b8021494Sopenharmony_ci} 1804b8021494Sopenharmony_ci 1805b8021494Sopenharmony_ci 1806b8021494Sopenharmony_ciTEST(fccmp_h) { 1807b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 1808b8021494Sopenharmony_ci 1809b8021494Sopenharmony_ci START(); 1810b8021494Sopenharmony_ci __ Fmov(h16, Float16(0.0)); 1811b8021494Sopenharmony_ci __ Fmov(h17, Float16(0.5)); 1812b8021494Sopenharmony_ci __ Mov(x20, 0); 1813b8021494Sopenharmony_ci __ Fmov(h21, kFP16DefaultNaN); 1814b8021494Sopenharmony_ci 1815b8021494Sopenharmony_ci __ Cmp(x20, 0); 1816b8021494Sopenharmony_ci __ Fccmp(h16, h16, NoFlag, eq); 1817b8021494Sopenharmony_ci __ Mrs(x0, NZCV); 1818b8021494Sopenharmony_ci 1819b8021494Sopenharmony_ci __ Cmp(x20, 0); 1820b8021494Sopenharmony_ci __ Fccmp(h16, h16, VFlag, ne); 1821b8021494Sopenharmony_ci __ Mrs(x1, NZCV); 1822b8021494Sopenharmony_ci 1823b8021494Sopenharmony_ci __ Cmp(x20, 0); 1824b8021494Sopenharmony_ci __ Fccmp(h16, h17, CFlag, ge); 1825b8021494Sopenharmony_ci __ Mrs(x2, NZCV); 1826b8021494Sopenharmony_ci 1827b8021494Sopenharmony_ci __ Cmp(x20, 0); 1828b8021494Sopenharmony_ci __ Fccmp(h16, h17, CVFlag, lt); 1829b8021494Sopenharmony_ci __ Mrs(x3, NZCV); 1830b8021494Sopenharmony_ci 1831b8021494Sopenharmony_ci // The Macro Assembler does not allow al or nv as condition. 1832b8021494Sopenharmony_ci { 1833b8021494Sopenharmony_ci ExactAssemblyScope scope(&masm, kInstructionSize); 1834b8021494Sopenharmony_ci __ fccmp(h16, h16, NFlag, al); 1835b8021494Sopenharmony_ci } 1836b8021494Sopenharmony_ci __ Mrs(x4, NZCV); 1837b8021494Sopenharmony_ci { 1838b8021494Sopenharmony_ci ExactAssemblyScope scope(&masm, kInstructionSize); 1839b8021494Sopenharmony_ci __ fccmp(h16, h16, NFlag, nv); 1840b8021494Sopenharmony_ci } 1841b8021494Sopenharmony_ci __ Mrs(x5, NZCV); 1842b8021494Sopenharmony_ci 1843b8021494Sopenharmony_ci __ Cmp(x20, 0); 1844b8021494Sopenharmony_ci __ Fccmpe(h16, h16, NoFlag, eq); 1845b8021494Sopenharmony_ci __ Mrs(x6, NZCV); 1846b8021494Sopenharmony_ci 1847b8021494Sopenharmony_ci __ Cmp(x20, 0); 1848b8021494Sopenharmony_ci __ Fccmpe(h16, h21, NoFlag, eq); 1849b8021494Sopenharmony_ci __ Mrs(x7, NZCV); 1850b8021494Sopenharmony_ci 1851b8021494Sopenharmony_ci __ Cmp(x20, 0); 1852b8021494Sopenharmony_ci __ Fccmpe(h21, h16, NoFlag, eq); 1853b8021494Sopenharmony_ci __ Mrs(x8, NZCV); 1854b8021494Sopenharmony_ci 1855b8021494Sopenharmony_ci __ Cmp(x20, 0); 1856b8021494Sopenharmony_ci __ Fccmpe(h21, h21, NoFlag, eq); 1857b8021494Sopenharmony_ci __ Mrs(x9, NZCV); 1858b8021494Sopenharmony_ci END(); 1859b8021494Sopenharmony_ci 1860b8021494Sopenharmony_ci if (CAN_RUN()) { 1861b8021494Sopenharmony_ci RUN(); 1862b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w0); 1863b8021494Sopenharmony_ci ASSERT_EQUAL_32(VFlag, w1); 1864b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w2); 1865b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w3); 1866b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w4); 1867b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w5); 1868b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w6); 1869b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w7); 1870b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w8); 1871b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w9); 1872b8021494Sopenharmony_ci } 1873b8021494Sopenharmony_ci} 1874b8021494Sopenharmony_ci 1875b8021494Sopenharmony_ci 1876b8021494Sopenharmony_ciTEST(fcmp) { 1877b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 1878b8021494Sopenharmony_ci 1879b8021494Sopenharmony_ci START(); 1880b8021494Sopenharmony_ci 1881b8021494Sopenharmony_ci // Some of these tests require a floating-point scratch register assigned to 1882b8021494Sopenharmony_ci // the macro assembler, but most do not. 1883b8021494Sopenharmony_ci { 1884b8021494Sopenharmony_ci UseScratchRegisterScope temps(&masm); 1885b8021494Sopenharmony_ci temps.ExcludeAll(); 1886b8021494Sopenharmony_ci temps.Include(ip0, ip1); 1887b8021494Sopenharmony_ci 1888b8021494Sopenharmony_ci __ Fmov(s8, 0.0); 1889b8021494Sopenharmony_ci __ Fmov(s9, 0.5); 1890b8021494Sopenharmony_ci __ Mov(w18, 0x7f800001); // Single precision NaN. 1891b8021494Sopenharmony_ci __ Fmov(s18, w18); 1892b8021494Sopenharmony_ci 1893b8021494Sopenharmony_ci __ Fcmp(s8, s8); 1894b8021494Sopenharmony_ci __ Mrs(x0, NZCV); 1895b8021494Sopenharmony_ci __ Fcmp(s8, s9); 1896b8021494Sopenharmony_ci __ Mrs(x1, NZCV); 1897b8021494Sopenharmony_ci __ Fcmp(s9, s8); 1898b8021494Sopenharmony_ci __ Mrs(x2, NZCV); 1899b8021494Sopenharmony_ci __ Fcmp(s8, s18); 1900b8021494Sopenharmony_ci __ Mrs(x3, NZCV); 1901b8021494Sopenharmony_ci __ Fcmp(s18, s18); 1902b8021494Sopenharmony_ci __ Mrs(x4, NZCV); 1903b8021494Sopenharmony_ci __ Fcmp(s8, 0.0); 1904b8021494Sopenharmony_ci __ Mrs(x5, NZCV); 1905b8021494Sopenharmony_ci temps.Include(d0); 1906b8021494Sopenharmony_ci __ Fcmp(s8, 255.0); 1907b8021494Sopenharmony_ci temps.Exclude(d0); 1908b8021494Sopenharmony_ci __ Mrs(x6, NZCV); 1909b8021494Sopenharmony_ci 1910b8021494Sopenharmony_ci __ Fmov(d19, 0.0); 1911b8021494Sopenharmony_ci __ Fmov(d20, 0.5); 1912b8021494Sopenharmony_ci __ Mov(x21, 0x7ff0000000000001); // Double precision NaN. 1913b8021494Sopenharmony_ci __ Fmov(d21, x21); 1914b8021494Sopenharmony_ci 1915b8021494Sopenharmony_ci __ Fcmp(d19, d19); 1916b8021494Sopenharmony_ci __ Mrs(x10, NZCV); 1917b8021494Sopenharmony_ci __ Fcmp(d19, d20); 1918b8021494Sopenharmony_ci __ Mrs(x11, NZCV); 1919b8021494Sopenharmony_ci __ Fcmp(d20, d19); 1920b8021494Sopenharmony_ci __ Mrs(x12, NZCV); 1921b8021494Sopenharmony_ci __ Fcmp(d19, d21); 1922b8021494Sopenharmony_ci __ Mrs(x13, NZCV); 1923b8021494Sopenharmony_ci __ Fcmp(d21, d21); 1924b8021494Sopenharmony_ci __ Mrs(x14, NZCV); 1925b8021494Sopenharmony_ci __ Fcmp(d19, 0.0); 1926b8021494Sopenharmony_ci __ Mrs(x15, NZCV); 1927b8021494Sopenharmony_ci temps.Include(d0); 1928b8021494Sopenharmony_ci __ Fcmp(d19, 12.3456); 1929b8021494Sopenharmony_ci temps.Exclude(d0); 1930b8021494Sopenharmony_ci __ Mrs(x16, NZCV); 1931b8021494Sopenharmony_ci 1932b8021494Sopenharmony_ci __ Fcmpe(s8, s8); 1933b8021494Sopenharmony_ci __ Mrs(x22, NZCV); 1934b8021494Sopenharmony_ci __ Fcmpe(s8, 0.0); 1935b8021494Sopenharmony_ci __ Mrs(x23, NZCV); 1936b8021494Sopenharmony_ci __ Fcmpe(d19, d19); 1937b8021494Sopenharmony_ci __ Mrs(x24, NZCV); 1938b8021494Sopenharmony_ci __ Fcmpe(d19, 0.0); 1939b8021494Sopenharmony_ci __ Mrs(x25, NZCV); 1940b8021494Sopenharmony_ci __ Fcmpe(s18, s18); 1941b8021494Sopenharmony_ci __ Mrs(x26, NZCV); 1942b8021494Sopenharmony_ci __ Fcmpe(d21, d21); 1943b8021494Sopenharmony_ci __ Mrs(x27, NZCV); 1944b8021494Sopenharmony_ci } 1945b8021494Sopenharmony_ci 1946b8021494Sopenharmony_ci END(); 1947b8021494Sopenharmony_ci 1948b8021494Sopenharmony_ci if (CAN_RUN()) { 1949b8021494Sopenharmony_ci RUN(); 1950b8021494Sopenharmony_ci 1951b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w0); 1952b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w1); 1953b8021494Sopenharmony_ci ASSERT_EQUAL_32(CFlag, w2); 1954b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w3); 1955b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w4); 1956b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w5); 1957b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w6); 1958b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w10); 1959b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w11); 1960b8021494Sopenharmony_ci ASSERT_EQUAL_32(CFlag, w12); 1961b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w13); 1962b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w14); 1963b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w15); 1964b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w16); 1965b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w22); 1966b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w23); 1967b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w24); 1968b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w25); 1969b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w26); 1970b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w27); 1971b8021494Sopenharmony_ci } 1972b8021494Sopenharmony_ci} 1973b8021494Sopenharmony_ci 1974b8021494Sopenharmony_ci 1975b8021494Sopenharmony_ciTEST(fcmp_h) { 1976b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 1977b8021494Sopenharmony_ci 1978b8021494Sopenharmony_ci START(); 1979b8021494Sopenharmony_ci 1980b8021494Sopenharmony_ci // Some of these tests require a floating-point scratch register assigned to 1981b8021494Sopenharmony_ci // the macro assembler, but most do not. 1982b8021494Sopenharmony_ci { 1983b8021494Sopenharmony_ci UseScratchRegisterScope temps(&masm); 1984b8021494Sopenharmony_ci temps.ExcludeAll(); 1985b8021494Sopenharmony_ci temps.Include(ip0, ip1); 1986b8021494Sopenharmony_ci 1987b8021494Sopenharmony_ci __ Fmov(h8, Float16(0.0)); 1988b8021494Sopenharmony_ci __ Fmov(h9, Float16(0.5)); 1989b8021494Sopenharmony_ci __ Fmov(h18, kFP16DefaultNaN); 1990b8021494Sopenharmony_ci 1991b8021494Sopenharmony_ci __ Fcmp(h8, h8); 1992b8021494Sopenharmony_ci __ Mrs(x0, NZCV); 1993b8021494Sopenharmony_ci __ Fcmp(h8, h9); 1994b8021494Sopenharmony_ci __ Mrs(x1, NZCV); 1995b8021494Sopenharmony_ci __ Fcmp(h9, h8); 1996b8021494Sopenharmony_ci __ Mrs(x2, NZCV); 1997b8021494Sopenharmony_ci __ Fcmp(h8, h18); 1998b8021494Sopenharmony_ci __ Mrs(x3, NZCV); 1999b8021494Sopenharmony_ci __ Fcmp(h18, h18); 2000b8021494Sopenharmony_ci __ Mrs(x4, NZCV); 2001b8021494Sopenharmony_ci __ Fcmp(h8, 0.0); 2002b8021494Sopenharmony_ci __ Mrs(x5, NZCV); 2003b8021494Sopenharmony_ci temps.Include(d0); 2004b8021494Sopenharmony_ci __ Fcmp(h8, 255.0); 2005b8021494Sopenharmony_ci temps.Exclude(d0); 2006b8021494Sopenharmony_ci __ Mrs(x6, NZCV); 2007b8021494Sopenharmony_ci 2008b8021494Sopenharmony_ci __ Fcmpe(h8, h8); 2009b8021494Sopenharmony_ci __ Mrs(x22, NZCV); 2010b8021494Sopenharmony_ci __ Fcmpe(h8, 0.0); 2011b8021494Sopenharmony_ci __ Mrs(x23, NZCV); 2012b8021494Sopenharmony_ci __ Fcmpe(h8, h18); 2013b8021494Sopenharmony_ci __ Mrs(x24, NZCV); 2014b8021494Sopenharmony_ci __ Fcmpe(h18, h8); 2015b8021494Sopenharmony_ci __ Mrs(x25, NZCV); 2016b8021494Sopenharmony_ci __ Fcmpe(h18, h18); 2017b8021494Sopenharmony_ci __ Mrs(x26, NZCV); 2018b8021494Sopenharmony_ci } 2019b8021494Sopenharmony_ci 2020b8021494Sopenharmony_ci END(); 2021b8021494Sopenharmony_ci 2022b8021494Sopenharmony_ci if (CAN_RUN()) { 2023b8021494Sopenharmony_ci RUN(); 2024b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w0); 2025b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w1); 2026b8021494Sopenharmony_ci ASSERT_EQUAL_32(CFlag, w2); 2027b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w3); 2028b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w4); 2029b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w5); 2030b8021494Sopenharmony_ci ASSERT_EQUAL_32(NFlag, w6); 2031b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w22); 2032b8021494Sopenharmony_ci ASSERT_EQUAL_32(ZCFlag, w23); 2033b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w24); 2034b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w25); 2035b8021494Sopenharmony_ci ASSERT_EQUAL_32(CVFlag, w26); 2036b8021494Sopenharmony_ci } 2037b8021494Sopenharmony_ci} 2038b8021494Sopenharmony_ci 2039b8021494Sopenharmony_ci 2040b8021494Sopenharmony_ciTEST(fcsel) { 2041b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 2042b8021494Sopenharmony_ci 2043b8021494Sopenharmony_ci START(); 2044b8021494Sopenharmony_ci __ Mov(x16, 0); 2045b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 2046b8021494Sopenharmony_ci __ Fmov(s17, 2.0); 2047b8021494Sopenharmony_ci __ Fmov(d18, 3.0); 2048b8021494Sopenharmony_ci __ Fmov(d19, 4.0); 2049b8021494Sopenharmony_ci 2050b8021494Sopenharmony_ci __ Cmp(x16, 0); 2051b8021494Sopenharmony_ci __ Fcsel(s0, s16, s17, eq); 2052b8021494Sopenharmony_ci __ Fcsel(s1, s16, s17, ne); 2053b8021494Sopenharmony_ci __ Fcsel(d2, d18, d19, eq); 2054b8021494Sopenharmony_ci __ Fcsel(d3, d18, d19, ne); 2055b8021494Sopenharmony_ci // The Macro Assembler does not allow al or nv as condition. 2056b8021494Sopenharmony_ci { 2057b8021494Sopenharmony_ci ExactAssemblyScope scope(&masm, 2 * kInstructionSize); 2058b8021494Sopenharmony_ci __ fcsel(s4, s16, s17, al); 2059b8021494Sopenharmony_ci __ fcsel(d5, d18, d19, nv); 2060b8021494Sopenharmony_ci } 2061b8021494Sopenharmony_ci END(); 2062b8021494Sopenharmony_ci 2063b8021494Sopenharmony_ci if (CAN_RUN()) { 2064b8021494Sopenharmony_ci RUN(); 2065b8021494Sopenharmony_ci 2066b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2067b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s1); 2068b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.0, d2); 2069b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(4.0, d3); 2070b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s4); 2071b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.0, d5); 2072b8021494Sopenharmony_ci } 2073b8021494Sopenharmony_ci} 2074b8021494Sopenharmony_ci 2075b8021494Sopenharmony_ci 2076b8021494Sopenharmony_ciTEST(fcsel_h) { 2077b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 2078b8021494Sopenharmony_ci 2079b8021494Sopenharmony_ci START(); 2080b8021494Sopenharmony_ci __ Mov(x16, 0); 2081b8021494Sopenharmony_ci __ Fmov(h16, Float16(1.0)); 2082b8021494Sopenharmony_ci __ Fmov(h17, Float16(2.0)); 2083b8021494Sopenharmony_ci 2084b8021494Sopenharmony_ci __ Cmp(x16, 0); 2085b8021494Sopenharmony_ci __ Fcsel(h0, h16, h17, eq); 2086b8021494Sopenharmony_ci __ Fcsel(h1, h16, h17, ne); 2087b8021494Sopenharmony_ci // The Macro Assembler does not allow al or nv as condition. 2088b8021494Sopenharmony_ci { 2089b8021494Sopenharmony_ci ExactAssemblyScope scope(&masm, 2 * kInstructionSize); 2090b8021494Sopenharmony_ci __ fcsel(h4, h16, h17, al); 2091b8021494Sopenharmony_ci __ fcsel(h5, h16, h17, nv); 2092b8021494Sopenharmony_ci } 2093b8021494Sopenharmony_ci END(); 2094b8021494Sopenharmony_ci 2095b8021494Sopenharmony_ci if (CAN_RUN()) { 2096b8021494Sopenharmony_ci RUN(); 2097b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.0), h0); 2098b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(2.0), h1); 2099b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.0), h4); 2100b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(Float16(1.0), h5); 2101b8021494Sopenharmony_ci } 2102b8021494Sopenharmony_ci} 2103b8021494Sopenharmony_ci 2104b8021494Sopenharmony_ci 2105b8021494Sopenharmony_ciTEST(fneg) { 2106b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 2107b8021494Sopenharmony_ci 2108b8021494Sopenharmony_ci START(); 2109b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 2110b8021494Sopenharmony_ci __ Fmov(s17, 0.0); 2111b8021494Sopenharmony_ci __ Fmov(s18, kFP32PositiveInfinity); 2112b8021494Sopenharmony_ci __ Fmov(d19, 1.0); 2113b8021494Sopenharmony_ci __ Fmov(d20, 0.0); 2114b8021494Sopenharmony_ci __ Fmov(d21, kFP64PositiveInfinity); 2115b8021494Sopenharmony_ci 2116b8021494Sopenharmony_ci __ Fneg(s0, s16); 2117b8021494Sopenharmony_ci __ Fneg(s1, s0); 2118b8021494Sopenharmony_ci __ Fneg(s2, s17); 2119b8021494Sopenharmony_ci __ Fneg(s3, s2); 2120b8021494Sopenharmony_ci __ Fneg(s4, s18); 2121b8021494Sopenharmony_ci __ Fneg(s5, s4); 2122b8021494Sopenharmony_ci __ Fneg(d6, d19); 2123b8021494Sopenharmony_ci __ Fneg(d7, d6); 2124b8021494Sopenharmony_ci __ Fneg(d8, d20); 2125b8021494Sopenharmony_ci __ Fneg(d9, d8); 2126b8021494Sopenharmony_ci __ Fneg(d10, d21); 2127b8021494Sopenharmony_ci __ Fneg(d11, d10); 2128b8021494Sopenharmony_ci END(); 2129b8021494Sopenharmony_ci 2130b8021494Sopenharmony_ci if (CAN_RUN()) { 2131b8021494Sopenharmony_ci RUN(); 2132b8021494Sopenharmony_ci 2133b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.0, s0); 2134b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2135b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s2); 2136b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s3); 2137b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s4); 2138b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s5); 2139b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.0, d6); 2140b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d7); 2141b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d8); 2142b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d9); 2143b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d10); 2144b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d11); 2145b8021494Sopenharmony_ci } 2146b8021494Sopenharmony_ci} 2147b8021494Sopenharmony_ci 2148b8021494Sopenharmony_ci 2149b8021494Sopenharmony_ciTEST(fabs) { 2150b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 2151b8021494Sopenharmony_ci 2152b8021494Sopenharmony_ci START(); 2153b8021494Sopenharmony_ci __ Fmov(s16, -1.0); 2154b8021494Sopenharmony_ci __ Fmov(s17, -0.0); 2155b8021494Sopenharmony_ci __ Fmov(s18, kFP32NegativeInfinity); 2156b8021494Sopenharmony_ci __ Fmov(d19, -1.0); 2157b8021494Sopenharmony_ci __ Fmov(d20, -0.0); 2158b8021494Sopenharmony_ci __ Fmov(d21, kFP64NegativeInfinity); 2159b8021494Sopenharmony_ci 2160b8021494Sopenharmony_ci __ Fabs(s0, s16); 2161b8021494Sopenharmony_ci __ Fabs(s1, s0); 2162b8021494Sopenharmony_ci __ Fabs(s2, s17); 2163b8021494Sopenharmony_ci __ Fabs(s3, s18); 2164b8021494Sopenharmony_ci __ Fabs(d4, d19); 2165b8021494Sopenharmony_ci __ Fabs(d5, d4); 2166b8021494Sopenharmony_ci __ Fabs(d6, d20); 2167b8021494Sopenharmony_ci __ Fabs(d7, d21); 2168b8021494Sopenharmony_ci END(); 2169b8021494Sopenharmony_ci 2170b8021494Sopenharmony_ci if (CAN_RUN()) { 2171b8021494Sopenharmony_ci RUN(); 2172b8021494Sopenharmony_ci 2173b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2174b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2175b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s2); 2176b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s3); 2177b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d4); 2178b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d5); 2179b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d6); 2180b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d7); 2181b8021494Sopenharmony_ci } 2182b8021494Sopenharmony_ci} 2183b8021494Sopenharmony_ci 2184b8021494Sopenharmony_ci 2185b8021494Sopenharmony_ciTEST(fsqrt) { 2186b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 2187b8021494Sopenharmony_ci 2188b8021494Sopenharmony_ci START(); 2189b8021494Sopenharmony_ci __ Fmov(s16, 0.0); 2190b8021494Sopenharmony_ci __ Fmov(s17, 1.0); 2191b8021494Sopenharmony_ci __ Fmov(s18, 0.25); 2192b8021494Sopenharmony_ci __ Fmov(s19, 65536.0); 2193b8021494Sopenharmony_ci __ Fmov(s20, -0.0); 2194b8021494Sopenharmony_ci __ Fmov(s21, kFP32PositiveInfinity); 2195b8021494Sopenharmony_ci __ Fmov(s22, -1.0); 2196b8021494Sopenharmony_ci __ Fmov(d23, 0.0); 2197b8021494Sopenharmony_ci __ Fmov(d24, 1.0); 2198b8021494Sopenharmony_ci __ Fmov(d25, 0.25); 2199b8021494Sopenharmony_ci __ Fmov(d26, 4294967296.0); 2200b8021494Sopenharmony_ci __ Fmov(d27, -0.0); 2201b8021494Sopenharmony_ci __ Fmov(d28, kFP64PositiveInfinity); 2202b8021494Sopenharmony_ci __ Fmov(d29, -1.0); 2203b8021494Sopenharmony_ci 2204b8021494Sopenharmony_ci __ Fsqrt(s0, s16); 2205b8021494Sopenharmony_ci __ Fsqrt(s1, s17); 2206b8021494Sopenharmony_ci __ Fsqrt(s2, s18); 2207b8021494Sopenharmony_ci __ Fsqrt(s3, s19); 2208b8021494Sopenharmony_ci __ Fsqrt(s4, s20); 2209b8021494Sopenharmony_ci __ Fsqrt(s5, s21); 2210b8021494Sopenharmony_ci __ Fsqrt(s6, s22); 2211b8021494Sopenharmony_ci __ Fsqrt(d7, d23); 2212b8021494Sopenharmony_ci __ Fsqrt(d8, d24); 2213b8021494Sopenharmony_ci __ Fsqrt(d9, d25); 2214b8021494Sopenharmony_ci __ Fsqrt(d10, d26); 2215b8021494Sopenharmony_ci __ Fsqrt(d11, d27); 2216b8021494Sopenharmony_ci __ Fsqrt(d12, d28); 2217b8021494Sopenharmony_ci __ Fsqrt(d13, d29); 2218b8021494Sopenharmony_ci END(); 2219b8021494Sopenharmony_ci 2220b8021494Sopenharmony_ci if (CAN_RUN()) { 2221b8021494Sopenharmony_ci RUN(); 2222b8021494Sopenharmony_ci 2223b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s0); 2224b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2225b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.5, s2); 2226b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(256.0, s3); 2227b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s4); 2228b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s5); 2229b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s6); 2230b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d7); 2231b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d8); 2232b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.5, d9); 2233b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(65536.0, d10); 2234b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d11); 2235b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP32PositiveInfinity, d12); 2236b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d13); 2237b8021494Sopenharmony_ci } 2238b8021494Sopenharmony_ci} 2239b8021494Sopenharmony_ci 2240b8021494Sopenharmony_ciTEST(frint32x_s) { 2241b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2242b8021494Sopenharmony_ci 2243b8021494Sopenharmony_ci START(); 2244b8021494Sopenharmony_ci 2245b8021494Sopenharmony_ci __ Fmov(s13, 1.0); 2246b8021494Sopenharmony_ci __ Fmov(s14, 1.1); 2247b8021494Sopenharmony_ci __ Fmov(s15, 1.5); 2248b8021494Sopenharmony_ci __ Fmov(s16, 1.9); 2249b8021494Sopenharmony_ci __ Fmov(s17, 2.5); 2250b8021494Sopenharmony_ci __ Fmov(s18, -1.5); 2251b8021494Sopenharmony_ci __ Fmov(s19, -2.5); 2252b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 2253b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 2254b8021494Sopenharmony_ci __ Fmov(s22, 0.0); 2255b8021494Sopenharmony_ci __ Fmov(s23, -0.0); 2256b8021494Sopenharmony_ci __ Fmov(s24, -0.2); 2257b8021494Sopenharmony_ci __ Fmov(s25, kFP32DefaultNaN); 2258b8021494Sopenharmony_ci __ Fmov(s26, INT32_MIN); 2259b8021494Sopenharmony_ci __ Fmov(s27, INT32_MIN + 0x80); // The next representable FP32. 2260b8021494Sopenharmony_ci __ Fmov(s28, 0x80000000); 2261b8021494Sopenharmony_ci __ Fmov(s29, 0x7fffff80); // The largest int32_t representable as FP32. 2262b8021494Sopenharmony_ci __ Fmov(s30, FLT_MIN); 2263b8021494Sopenharmony_ci __ Fmov(s31, FLT_MAX); 2264b8021494Sopenharmony_ci 2265b8021494Sopenharmony_ci __ Frint32x(s0, s13); 2266b8021494Sopenharmony_ci __ Frint32x(s1, s14); 2267b8021494Sopenharmony_ci __ Frint32x(s2, s15); 2268b8021494Sopenharmony_ci __ Frint32x(s3, s16); 2269b8021494Sopenharmony_ci __ Frint32x(s4, s17); 2270b8021494Sopenharmony_ci __ Frint32x(s5, s18); 2271b8021494Sopenharmony_ci __ Frint32x(s6, s19); 2272b8021494Sopenharmony_ci __ Frint32x(s7, s20); 2273b8021494Sopenharmony_ci __ Frint32x(s8, s21); 2274b8021494Sopenharmony_ci __ Frint32x(s9, s22); 2275b8021494Sopenharmony_ci __ Frint32x(s10, s23); 2276b8021494Sopenharmony_ci __ Frint32x(s11, s24); 2277b8021494Sopenharmony_ci __ Frint32x(s12, s25); 2278b8021494Sopenharmony_ci __ Frint32x(s13, s26); 2279b8021494Sopenharmony_ci __ Frint32x(s14, s27); 2280b8021494Sopenharmony_ci __ Frint32x(s15, s28); 2281b8021494Sopenharmony_ci __ Frint32x(s16, s29); 2282b8021494Sopenharmony_ci __ Frint32x(s17, s30); 2283b8021494Sopenharmony_ci __ Frint32x(s18, s31); 2284b8021494Sopenharmony_ci 2285b8021494Sopenharmony_ci END(); 2286b8021494Sopenharmony_ci 2287b8021494Sopenharmony_ci if (CAN_RUN()) { 2288b8021494Sopenharmony_ci RUN(); 2289b8021494Sopenharmony_ci 2290b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2291b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2292b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s2); 2293b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s3); 2294b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 2295b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s5); 2296b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 2297b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s7); 2298b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s8); 2299b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 2300b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 2301b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 2302b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s12); // NaN. 2303b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s13); 2304b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN + 0x80, s14); 2305b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s15); // Out of range. 2306b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0x7fffff80, s16); 2307b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0, s17); 2308b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s18); 2309b8021494Sopenharmony_ci } 2310b8021494Sopenharmony_ci} 2311b8021494Sopenharmony_ci 2312b8021494Sopenharmony_ciTEST(frint32x_d) { 2313b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2314b8021494Sopenharmony_ci 2315b8021494Sopenharmony_ci START(); 2316b8021494Sopenharmony_ci 2317b8021494Sopenharmony_ci __ Fmov(d13, 1.0); 2318b8021494Sopenharmony_ci __ Fmov(d14, 1.1); 2319b8021494Sopenharmony_ci __ Fmov(d15, 1.5); 2320b8021494Sopenharmony_ci __ Fmov(d16, 1.9); 2321b8021494Sopenharmony_ci __ Fmov(d17, 2.5); 2322b8021494Sopenharmony_ci __ Fmov(d18, -1.5); 2323b8021494Sopenharmony_ci __ Fmov(d19, -2.5); 2324b8021494Sopenharmony_ci __ Fmov(d20, kFP64PositiveInfinity); 2325b8021494Sopenharmony_ci __ Fmov(d21, kFP64NegativeInfinity); 2326b8021494Sopenharmony_ci __ Fmov(d22, 0.0); 2327b8021494Sopenharmony_ci __ Fmov(d23, -0.0); 2328b8021494Sopenharmony_ci __ Fmov(d24, -0.2); 2329b8021494Sopenharmony_ci __ Fmov(d25, kFP64DefaultNaN); 2330b8021494Sopenharmony_ci __ Fmov(d26, INT32_MIN); 2331b8021494Sopenharmony_ci __ Fmov(d27, INT32_MIN + 1); 2332b8021494Sopenharmony_ci __ Fmov(d28, INT32_MAX); 2333b8021494Sopenharmony_ci __ Fmov(d29, INT32_MAX - 1); 2334b8021494Sopenharmony_ci __ Fmov(d30, FLT_MIN); 2335b8021494Sopenharmony_ci __ Fmov(d31, FLT_MAX); 2336b8021494Sopenharmony_ci 2337b8021494Sopenharmony_ci __ Frint32x(d0, d13); 2338b8021494Sopenharmony_ci __ Frint32x(d1, d14); 2339b8021494Sopenharmony_ci __ Frint32x(d2, d15); 2340b8021494Sopenharmony_ci __ Frint32x(d3, d16); 2341b8021494Sopenharmony_ci __ Frint32x(d4, d17); 2342b8021494Sopenharmony_ci __ Frint32x(d5, d18); 2343b8021494Sopenharmony_ci __ Frint32x(d6, d19); 2344b8021494Sopenharmony_ci __ Frint32x(d7, d20); 2345b8021494Sopenharmony_ci __ Frint32x(d8, d21); 2346b8021494Sopenharmony_ci __ Frint32x(d9, d22); 2347b8021494Sopenharmony_ci __ Frint32x(d10, d23); 2348b8021494Sopenharmony_ci __ Frint32x(d11, d24); 2349b8021494Sopenharmony_ci __ Frint32x(d12, d25); 2350b8021494Sopenharmony_ci __ Frint32x(d13, d26); 2351b8021494Sopenharmony_ci __ Frint32x(d14, d27); 2352b8021494Sopenharmony_ci __ Frint32x(d15, d28); 2353b8021494Sopenharmony_ci __ Frint32x(d16, d29); 2354b8021494Sopenharmony_ci __ Frint32x(d17, d30); 2355b8021494Sopenharmony_ci __ Frint32x(d18, d31); 2356b8021494Sopenharmony_ci 2357b8021494Sopenharmony_ci END(); 2358b8021494Sopenharmony_ci 2359b8021494Sopenharmony_ci if (CAN_RUN()) { 2360b8021494Sopenharmony_ci RUN(); 2361b8021494Sopenharmony_ci 2362b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d0); 2363b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d1); 2364b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d2); 2365b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d3); 2366b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d4); 2367b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d5); 2368b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d6); 2369b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d7); 2370b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d8); 2371b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d9); 2372b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d10); 2373b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d11); 2374b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d12); 2375b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d13); 2376b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN + 1, d14); 2377b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MAX, d15); 2378b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MAX - 1, d16); 2379b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0, d17); 2380b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d18); 2381b8021494Sopenharmony_ci } 2382b8021494Sopenharmony_ci} 2383b8021494Sopenharmony_ci 2384b8021494Sopenharmony_ciTEST(frint32z_s) { 2385b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2386b8021494Sopenharmony_ci 2387b8021494Sopenharmony_ci START(); 2388b8021494Sopenharmony_ci 2389b8021494Sopenharmony_ci __ Fmov(s13, 1.0); 2390b8021494Sopenharmony_ci __ Fmov(s14, 1.1); 2391b8021494Sopenharmony_ci __ Fmov(s15, 1.5); 2392b8021494Sopenharmony_ci __ Fmov(s16, 1.9); 2393b8021494Sopenharmony_ci __ Fmov(s17, 2.5); 2394b8021494Sopenharmony_ci __ Fmov(s18, -1.5); 2395b8021494Sopenharmony_ci __ Fmov(s19, -2.5); 2396b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 2397b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 2398b8021494Sopenharmony_ci __ Fmov(s22, 0.0); 2399b8021494Sopenharmony_ci __ Fmov(s23, -0.0); 2400b8021494Sopenharmony_ci __ Fmov(s24, -0.2); 2401b8021494Sopenharmony_ci __ Fmov(s25, kFP32DefaultNaN); 2402b8021494Sopenharmony_ci __ Fmov(s26, INT32_MIN); 2403b8021494Sopenharmony_ci __ Fmov(s27, INT32_MIN + 0x80); // The next representable FP32. 2404b8021494Sopenharmony_ci __ Fmov(s28, 0x80000000); 2405b8021494Sopenharmony_ci __ Fmov(s29, 0x7fffff80); // The largest int32_t representable as FP32. 2406b8021494Sopenharmony_ci __ Fmov(s30, FLT_MIN); 2407b8021494Sopenharmony_ci __ Fmov(s31, FLT_MAX); 2408b8021494Sopenharmony_ci 2409b8021494Sopenharmony_ci __ Frint32z(s0, s13); 2410b8021494Sopenharmony_ci __ Frint32z(s1, s14); 2411b8021494Sopenharmony_ci __ Frint32z(s2, s15); 2412b8021494Sopenharmony_ci __ Frint32z(s3, s16); 2413b8021494Sopenharmony_ci __ Frint32z(s4, s17); 2414b8021494Sopenharmony_ci __ Frint32z(s5, s18); 2415b8021494Sopenharmony_ci __ Frint32z(s6, s19); 2416b8021494Sopenharmony_ci __ Frint32z(s7, s20); 2417b8021494Sopenharmony_ci __ Frint32z(s8, s21); 2418b8021494Sopenharmony_ci __ Frint32z(s9, s22); 2419b8021494Sopenharmony_ci __ Frint32z(s10, s23); 2420b8021494Sopenharmony_ci __ Frint32z(s11, s24); 2421b8021494Sopenharmony_ci __ Frint32z(s12, s25); 2422b8021494Sopenharmony_ci __ Frint32z(s13, s26); 2423b8021494Sopenharmony_ci __ Frint32z(s14, s27); 2424b8021494Sopenharmony_ci __ Frint32z(s15, s28); 2425b8021494Sopenharmony_ci __ Frint32z(s16, s29); 2426b8021494Sopenharmony_ci __ Frint32z(s17, s30); 2427b8021494Sopenharmony_ci __ Frint32z(s18, s31); 2428b8021494Sopenharmony_ci 2429b8021494Sopenharmony_ci END(); 2430b8021494Sopenharmony_ci 2431b8021494Sopenharmony_ci if (CAN_RUN()) { 2432b8021494Sopenharmony_ci RUN(); 2433b8021494Sopenharmony_ci 2434b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2435b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2436b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s2); 2437b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s3); 2438b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 2439b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.0, s5); 2440b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 2441b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s7); 2442b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s8); 2443b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 2444b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 2445b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 2446b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s12); // NaN. 2447b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s13); 2448b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN + 0x80, s14); 2449b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s15); // Out of range. 2450b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0x7fffff80, s16); 2451b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0, s17); 2452b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT32_MIN, s18); 2453b8021494Sopenharmony_ci } 2454b8021494Sopenharmony_ci} 2455b8021494Sopenharmony_ci 2456b8021494Sopenharmony_ciTEST(frint32z_d) { 2457b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2458b8021494Sopenharmony_ci 2459b8021494Sopenharmony_ci START(); 2460b8021494Sopenharmony_ci 2461b8021494Sopenharmony_ci __ Fmov(d13, 1.0); 2462b8021494Sopenharmony_ci __ Fmov(d14, 1.1); 2463b8021494Sopenharmony_ci __ Fmov(d15, 1.5); 2464b8021494Sopenharmony_ci __ Fmov(d16, 1.9); 2465b8021494Sopenharmony_ci __ Fmov(d17, 2.5); 2466b8021494Sopenharmony_ci __ Fmov(d18, -1.5); 2467b8021494Sopenharmony_ci __ Fmov(d19, -2.5); 2468b8021494Sopenharmony_ci __ Fmov(d20, kFP64PositiveInfinity); 2469b8021494Sopenharmony_ci __ Fmov(d21, kFP64NegativeInfinity); 2470b8021494Sopenharmony_ci __ Fmov(d22, 0.0); 2471b8021494Sopenharmony_ci __ Fmov(d23, -0.0); 2472b8021494Sopenharmony_ci __ Fmov(d24, -0.2); 2473b8021494Sopenharmony_ci __ Fmov(d25, kFP64DefaultNaN); 2474b8021494Sopenharmony_ci __ Fmov(d26, INT32_MIN); 2475b8021494Sopenharmony_ci __ Fmov(d27, INT32_MIN + 1); 2476b8021494Sopenharmony_ci __ Fmov(d28, INT32_MAX); 2477b8021494Sopenharmony_ci __ Fmov(d29, INT32_MAX - 1); 2478b8021494Sopenharmony_ci __ Fmov(d30, FLT_MIN); 2479b8021494Sopenharmony_ci __ Fmov(d31, FLT_MAX); 2480b8021494Sopenharmony_ci 2481b8021494Sopenharmony_ci __ Frint32z(d0, d13); 2482b8021494Sopenharmony_ci __ Frint32z(d1, d14); 2483b8021494Sopenharmony_ci __ Frint32z(d2, d15); 2484b8021494Sopenharmony_ci __ Frint32z(d3, d16); 2485b8021494Sopenharmony_ci __ Frint32z(d4, d17); 2486b8021494Sopenharmony_ci __ Frint32z(d5, d18); 2487b8021494Sopenharmony_ci __ Frint32z(d6, d19); 2488b8021494Sopenharmony_ci __ Frint32z(d7, d20); 2489b8021494Sopenharmony_ci __ Frint32z(d8, d21); 2490b8021494Sopenharmony_ci __ Frint32z(d9, d22); 2491b8021494Sopenharmony_ci __ Frint32z(d10, d23); 2492b8021494Sopenharmony_ci __ Frint32z(d11, d24); 2493b8021494Sopenharmony_ci __ Frint32z(d12, d25); 2494b8021494Sopenharmony_ci __ Frint32z(d13, d26); 2495b8021494Sopenharmony_ci __ Frint32z(d14, d27); 2496b8021494Sopenharmony_ci __ Frint32z(d15, d28); 2497b8021494Sopenharmony_ci __ Frint32z(d16, d29); 2498b8021494Sopenharmony_ci __ Frint32z(d17, d30); 2499b8021494Sopenharmony_ci __ Frint32z(d18, d31); 2500b8021494Sopenharmony_ci 2501b8021494Sopenharmony_ci END(); 2502b8021494Sopenharmony_ci 2503b8021494Sopenharmony_ci if (CAN_RUN()) { 2504b8021494Sopenharmony_ci RUN(); 2505b8021494Sopenharmony_ci 2506b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d0); 2507b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d1); 2508b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d2); 2509b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d3); 2510b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d4); 2511b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.0, d5); 2512b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d6); 2513b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d7); 2514b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d8); 2515b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d9); 2516b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d10); 2517b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d11); 2518b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d12); 2519b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d13); 2520b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN + 1, d14); 2521b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MAX, d15); 2522b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MAX - 1, d16); 2523b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0, d17); 2524b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT32_MIN, d18); 2525b8021494Sopenharmony_ci } 2526b8021494Sopenharmony_ci} 2527b8021494Sopenharmony_ci 2528b8021494Sopenharmony_ciTEST(frint64x_s) { 2529b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2530b8021494Sopenharmony_ci 2531b8021494Sopenharmony_ci START(); 2532b8021494Sopenharmony_ci 2533b8021494Sopenharmony_ci __ Fmov(s13, 1.0); 2534b8021494Sopenharmony_ci __ Fmov(s14, 1.1); 2535b8021494Sopenharmony_ci __ Fmov(s15, 1.5); 2536b8021494Sopenharmony_ci __ Fmov(s16, 1.9); 2537b8021494Sopenharmony_ci __ Fmov(s17, 2.5); 2538b8021494Sopenharmony_ci __ Fmov(s18, -1.5); 2539b8021494Sopenharmony_ci __ Fmov(s19, -2.5); 2540b8021494Sopenharmony_ci __ Fmov(s20, kFP64PositiveInfinity); 2541b8021494Sopenharmony_ci __ Fmov(s21, kFP64NegativeInfinity); 2542b8021494Sopenharmony_ci __ Fmov(s22, 0.0); 2543b8021494Sopenharmony_ci __ Fmov(s23, -0.0); 2544b8021494Sopenharmony_ci __ Fmov(s24, -0.2); 2545b8021494Sopenharmony_ci __ Fmov(s25, kFP64DefaultNaN); 2546b8021494Sopenharmony_ci __ Fmov(s26, INT64_MIN); 2547b8021494Sopenharmony_ci __ Fmov(s27, INT64_MIN + 0x80'00000000); // The next representable FP32. 2548b8021494Sopenharmony_ci __ Fmov(s28, 0x80000000'00000000); 2549b8021494Sopenharmony_ci // The largest int64_t representable as FP32. 2550b8021494Sopenharmony_ci __ Fmov(s29, 0x7fffff80'00000000); 2551b8021494Sopenharmony_ci __ Fmov(s30, FLT_MIN); 2552b8021494Sopenharmony_ci __ Fmov(s31, FLT_MAX); 2553b8021494Sopenharmony_ci 2554b8021494Sopenharmony_ci __ Frint64x(s0, s13); 2555b8021494Sopenharmony_ci __ Frint64x(s1, s14); 2556b8021494Sopenharmony_ci __ Frint64x(s2, s15); 2557b8021494Sopenharmony_ci __ Frint64x(s3, s16); 2558b8021494Sopenharmony_ci __ Frint64x(s4, s17); 2559b8021494Sopenharmony_ci __ Frint64x(s5, s18); 2560b8021494Sopenharmony_ci __ Frint64x(s6, s19); 2561b8021494Sopenharmony_ci __ Frint64x(s7, s20); 2562b8021494Sopenharmony_ci __ Frint64x(s8, s21); 2563b8021494Sopenharmony_ci __ Frint64x(s9, s22); 2564b8021494Sopenharmony_ci __ Frint64x(s10, s23); 2565b8021494Sopenharmony_ci __ Frint64x(s11, s24); 2566b8021494Sopenharmony_ci __ Frint64x(s12, s25); 2567b8021494Sopenharmony_ci __ Frint64x(s13, s26); 2568b8021494Sopenharmony_ci __ Frint64x(s14, s27); 2569b8021494Sopenharmony_ci __ Frint64x(s15, s28); 2570b8021494Sopenharmony_ci __ Frint64x(s16, s29); 2571b8021494Sopenharmony_ci __ Frint64x(s17, s30); 2572b8021494Sopenharmony_ci __ Frint64x(s18, s31); 2573b8021494Sopenharmony_ci 2574b8021494Sopenharmony_ci END(); 2575b8021494Sopenharmony_ci 2576b8021494Sopenharmony_ci if (CAN_RUN()) { 2577b8021494Sopenharmony_ci RUN(); 2578b8021494Sopenharmony_ci 2579b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2580b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2581b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s2); 2582b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s3); 2583b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 2584b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s5); 2585b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 2586b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s7); 2587b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s8); 2588b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 2589b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 2590b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 2591b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s12); // Nan. 2592b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s13); 2593b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN + 0x80'00000000, s14); 2594b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s15); // Out of range. 2595b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0x7fffff80'00000000, s16); 2596b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0, s17); 2597b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s18); 2598b8021494Sopenharmony_ci } 2599b8021494Sopenharmony_ci} 2600b8021494Sopenharmony_ci 2601b8021494Sopenharmony_ciTEST(frint64x_d) { 2602b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2603b8021494Sopenharmony_ci 2604b8021494Sopenharmony_ci START(); 2605b8021494Sopenharmony_ci 2606b8021494Sopenharmony_ci __ Fmov(d13, 1.0); 2607b8021494Sopenharmony_ci __ Fmov(d14, 1.1); 2608b8021494Sopenharmony_ci __ Fmov(d15, 1.5); 2609b8021494Sopenharmony_ci __ Fmov(d16, 1.9); 2610b8021494Sopenharmony_ci __ Fmov(d17, 2.5); 2611b8021494Sopenharmony_ci __ Fmov(d18, -1.5); 2612b8021494Sopenharmony_ci __ Fmov(d19, -2.5); 2613b8021494Sopenharmony_ci __ Fmov(d20, kFP64PositiveInfinity); 2614b8021494Sopenharmony_ci __ Fmov(d21, kFP64NegativeInfinity); 2615b8021494Sopenharmony_ci __ Fmov(d22, 0.0); 2616b8021494Sopenharmony_ci __ Fmov(d23, -0.0); 2617b8021494Sopenharmony_ci __ Fmov(d24, -0.2); 2618b8021494Sopenharmony_ci __ Fmov(d25, kFP64DefaultNaN); 2619b8021494Sopenharmony_ci __ Fmov(d26, INT64_MIN); 2620b8021494Sopenharmony_ci __ Fmov(d27, INT64_MIN + 0x400); // The next representable FP64. 2621b8021494Sopenharmony_ci __ Fmov(d28, 0x80000000'00000000); 2622b8021494Sopenharmony_ci // The largest int64_t representable as FP64. 2623b8021494Sopenharmony_ci __ Fmov(d29, 0x7fffffff'fffffc00); 2624b8021494Sopenharmony_ci __ Fmov(d30, FLT_MIN); 2625b8021494Sopenharmony_ci __ Fmov(d31, FLT_MAX); 2626b8021494Sopenharmony_ci 2627b8021494Sopenharmony_ci __ Frint64x(d0, d13); 2628b8021494Sopenharmony_ci __ Frint64x(d1, d14); 2629b8021494Sopenharmony_ci __ Frint64x(d2, d15); 2630b8021494Sopenharmony_ci __ Frint64x(d3, d16); 2631b8021494Sopenharmony_ci __ Frint64x(d4, d17); 2632b8021494Sopenharmony_ci __ Frint64x(d5, d18); 2633b8021494Sopenharmony_ci __ Frint64x(d6, d19); 2634b8021494Sopenharmony_ci __ Frint64x(d7, d20); 2635b8021494Sopenharmony_ci __ Frint64x(d8, d21); 2636b8021494Sopenharmony_ci __ Frint64x(d9, d22); 2637b8021494Sopenharmony_ci __ Frint64x(d10, d23); 2638b8021494Sopenharmony_ci __ Frint64x(d11, d24); 2639b8021494Sopenharmony_ci __ Frint64x(d12, d25); 2640b8021494Sopenharmony_ci __ Frint64x(d13, d26); 2641b8021494Sopenharmony_ci __ Frint64x(d14, d27); 2642b8021494Sopenharmony_ci __ Frint64x(d15, d28); 2643b8021494Sopenharmony_ci __ Frint64x(d16, d29); 2644b8021494Sopenharmony_ci __ Frint64x(d17, d30); 2645b8021494Sopenharmony_ci __ Frint64x(d18, d31); 2646b8021494Sopenharmony_ci 2647b8021494Sopenharmony_ci END(); 2648b8021494Sopenharmony_ci 2649b8021494Sopenharmony_ci if (CAN_RUN()) { 2650b8021494Sopenharmony_ci RUN(); 2651b8021494Sopenharmony_ci 2652b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d0); 2653b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d1); 2654b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d2); 2655b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d3); 2656b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d4); 2657b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d5); 2658b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d6); 2659b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d7); 2660b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d8); 2661b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d9); 2662b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d10); 2663b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d11); 2664b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d12); // NaN. 2665b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d13); 2666b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN + 0x400, d14); 2667b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d15); // Out of range. 2668b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0x7fffffff'fffffc00, d16); 2669b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0, d17); 2670b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d18); 2671b8021494Sopenharmony_ci } 2672b8021494Sopenharmony_ci} 2673b8021494Sopenharmony_ci 2674b8021494Sopenharmony_ciTEST(frint64z_s) { 2675b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2676b8021494Sopenharmony_ci 2677b8021494Sopenharmony_ci START(); 2678b8021494Sopenharmony_ci 2679b8021494Sopenharmony_ci __ Fmov(s13, 1.0); 2680b8021494Sopenharmony_ci __ Fmov(s14, 1.1); 2681b8021494Sopenharmony_ci __ Fmov(s15, 1.5); 2682b8021494Sopenharmony_ci __ Fmov(s16, 1.9); 2683b8021494Sopenharmony_ci __ Fmov(s17, 2.5); 2684b8021494Sopenharmony_ci __ Fmov(s18, -1.5); 2685b8021494Sopenharmony_ci __ Fmov(s19, -2.5); 2686b8021494Sopenharmony_ci __ Fmov(s20, kFP64PositiveInfinity); 2687b8021494Sopenharmony_ci __ Fmov(s21, kFP64NegativeInfinity); 2688b8021494Sopenharmony_ci __ Fmov(s22, 0.0); 2689b8021494Sopenharmony_ci __ Fmov(s23, -0.0); 2690b8021494Sopenharmony_ci __ Fmov(s24, -0.2); 2691b8021494Sopenharmony_ci __ Fmov(s25, kFP64DefaultNaN); 2692b8021494Sopenharmony_ci __ Fmov(s26, INT64_MIN); 2693b8021494Sopenharmony_ci __ Fmov(s27, INT64_MIN + 0x80'00000000); // The next representable FP32. 2694b8021494Sopenharmony_ci __ Fmov(s28, 0x80000000'00000000); 2695b8021494Sopenharmony_ci // The largest int64_t representable as FP32. 2696b8021494Sopenharmony_ci __ Fmov(s29, 0x7fffff80'00000000); 2697b8021494Sopenharmony_ci __ Fmov(s30, FLT_MIN); 2698b8021494Sopenharmony_ci __ Fmov(s31, FLT_MAX); 2699b8021494Sopenharmony_ci 2700b8021494Sopenharmony_ci __ Frint64z(s0, s13); 2701b8021494Sopenharmony_ci __ Frint64z(s1, s14); 2702b8021494Sopenharmony_ci __ Frint64z(s2, s15); 2703b8021494Sopenharmony_ci __ Frint64z(s3, s16); 2704b8021494Sopenharmony_ci __ Frint64z(s4, s17); 2705b8021494Sopenharmony_ci __ Frint64z(s5, s18); 2706b8021494Sopenharmony_ci __ Frint64z(s6, s19); 2707b8021494Sopenharmony_ci __ Frint64z(s7, s20); 2708b8021494Sopenharmony_ci __ Frint64z(s8, s21); 2709b8021494Sopenharmony_ci __ Frint64z(s9, s22); 2710b8021494Sopenharmony_ci __ Frint64z(s10, s23); 2711b8021494Sopenharmony_ci __ Frint64z(s11, s24); 2712b8021494Sopenharmony_ci __ Frint64z(s12, s25); 2713b8021494Sopenharmony_ci __ Frint64z(s13, s26); 2714b8021494Sopenharmony_ci __ Frint64z(s14, s27); 2715b8021494Sopenharmony_ci __ Frint64z(s15, s28); 2716b8021494Sopenharmony_ci __ Frint64z(s16, s29); 2717b8021494Sopenharmony_ci __ Frint64z(s17, s30); 2718b8021494Sopenharmony_ci __ Frint64z(s18, s31); 2719b8021494Sopenharmony_ci 2720b8021494Sopenharmony_ci END(); 2721b8021494Sopenharmony_ci 2722b8021494Sopenharmony_ci if (CAN_RUN()) { 2723b8021494Sopenharmony_ci RUN(); 2724b8021494Sopenharmony_ci 2725b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2726b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2727b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s2); 2728b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s3); 2729b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 2730b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.0, s5); 2731b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 2732b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s7); 2733b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s8); 2734b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 2735b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 2736b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 2737b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s12); // Nan. 2738b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s13); 2739b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN + 0x80'00000000, s14); 2740b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s15); // Out of range. 2741b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0x7fffff80'00000000, s16); 2742b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0, s17); 2743b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(INT64_MIN, s18); 2744b8021494Sopenharmony_ci } 2745b8021494Sopenharmony_ci} 2746b8021494Sopenharmony_ci 2747b8021494Sopenharmony_ciTEST(frint64z_d) { 2748b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFrintToFixedSizedInt); 2749b8021494Sopenharmony_ci 2750b8021494Sopenharmony_ci START(); 2751b8021494Sopenharmony_ci 2752b8021494Sopenharmony_ci __ Fmov(d13, 1.0); 2753b8021494Sopenharmony_ci __ Fmov(d14, 1.1); 2754b8021494Sopenharmony_ci __ Fmov(d15, 1.5); 2755b8021494Sopenharmony_ci __ Fmov(d16, 1.9); 2756b8021494Sopenharmony_ci __ Fmov(d17, 2.5); 2757b8021494Sopenharmony_ci __ Fmov(d18, -1.5); 2758b8021494Sopenharmony_ci __ Fmov(d19, -2.5); 2759b8021494Sopenharmony_ci __ Fmov(d20, kFP64PositiveInfinity); 2760b8021494Sopenharmony_ci __ Fmov(d21, kFP64NegativeInfinity); 2761b8021494Sopenharmony_ci __ Fmov(d22, 0.0); 2762b8021494Sopenharmony_ci __ Fmov(d23, -0.0); 2763b8021494Sopenharmony_ci __ Fmov(d24, -0.2); 2764b8021494Sopenharmony_ci __ Fmov(d25, kFP64DefaultNaN); 2765b8021494Sopenharmony_ci __ Fmov(d26, INT64_MIN); 2766b8021494Sopenharmony_ci __ Fmov(d27, INT64_MIN + 0x400); // The next representable FP64. 2767b8021494Sopenharmony_ci __ Fmov(d28, 0x80000000'00000000); 2768b8021494Sopenharmony_ci // The largest int64_t representable as FP64. 2769b8021494Sopenharmony_ci __ Fmov(d29, 0x7fffffff'fffffc00); 2770b8021494Sopenharmony_ci __ Fmov(d30, FLT_MIN); 2771b8021494Sopenharmony_ci __ Fmov(d31, FLT_MAX); 2772b8021494Sopenharmony_ci 2773b8021494Sopenharmony_ci __ Frint64z(d0, d13); 2774b8021494Sopenharmony_ci __ Frint64z(d1, d14); 2775b8021494Sopenharmony_ci __ Frint64z(d2, d15); 2776b8021494Sopenharmony_ci __ Frint64z(d3, d16); 2777b8021494Sopenharmony_ci __ Frint64z(d4, d17); 2778b8021494Sopenharmony_ci __ Frint64z(d5, d18); 2779b8021494Sopenharmony_ci __ Frint64z(d6, d19); 2780b8021494Sopenharmony_ci __ Frint64z(d7, d20); 2781b8021494Sopenharmony_ci __ Frint64z(d8, d21); 2782b8021494Sopenharmony_ci __ Frint64z(d9, d22); 2783b8021494Sopenharmony_ci __ Frint64z(d10, d23); 2784b8021494Sopenharmony_ci __ Frint64z(d11, d24); 2785b8021494Sopenharmony_ci __ Frint64z(d12, d25); 2786b8021494Sopenharmony_ci __ Frint64z(d13, d26); 2787b8021494Sopenharmony_ci __ Frint64z(d14, d27); 2788b8021494Sopenharmony_ci __ Frint64z(d15, d28); 2789b8021494Sopenharmony_ci __ Frint64z(d16, d29); 2790b8021494Sopenharmony_ci __ Frint64z(d17, d30); 2791b8021494Sopenharmony_ci __ Frint64z(d18, d31); 2792b8021494Sopenharmony_ci 2793b8021494Sopenharmony_ci END(); 2794b8021494Sopenharmony_ci 2795b8021494Sopenharmony_ci if (CAN_RUN()) { 2796b8021494Sopenharmony_ci RUN(); 2797b8021494Sopenharmony_ci 2798b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d0); 2799b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d1); 2800b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d2); 2801b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d3); 2802b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d4); 2803b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.0, d5); 2804b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d6); 2805b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d7); 2806b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d8); 2807b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d9); 2808b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d10); 2809b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d11); 2810b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d12); // NaN. 2811b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d13); 2812b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN + 0x400, d14); 2813b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d15); // Out of range. 2814b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0x7fffffff'fffffc00, d16); 2815b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0, d17); 2816b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(INT64_MIN, d18); 2817b8021494Sopenharmony_ci } 2818b8021494Sopenharmony_ci} 2819b8021494Sopenharmony_ci 2820b8021494Sopenharmony_ciTEST(frinta) { 2821b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 2822b8021494Sopenharmony_ci 2823b8021494Sopenharmony_ci START(); 2824b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 2825b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 2826b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 2827b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 2828b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 2829b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 2830b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 2831b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 2832b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 2833b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 2834b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 2835b8021494Sopenharmony_ci __ Fmov(s27, -0.2); 2836b8021494Sopenharmony_ci 2837b8021494Sopenharmony_ci __ Frinta(s0, s16); 2838b8021494Sopenharmony_ci __ Frinta(s1, s17); 2839b8021494Sopenharmony_ci __ Frinta(s2, s18); 2840b8021494Sopenharmony_ci __ Frinta(s3, s19); 2841b8021494Sopenharmony_ci __ Frinta(s4, s20); 2842b8021494Sopenharmony_ci __ Frinta(s5, s21); 2843b8021494Sopenharmony_ci __ Frinta(s6, s22); 2844b8021494Sopenharmony_ci __ Frinta(s7, s23); 2845b8021494Sopenharmony_ci __ Frinta(s8, s24); 2846b8021494Sopenharmony_ci __ Frinta(s9, s25); 2847b8021494Sopenharmony_ci __ Frinta(s10, s26); 2848b8021494Sopenharmony_ci __ Frinta(s11, s27); 2849b8021494Sopenharmony_ci 2850b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 2851b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 2852b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 2853b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 2854b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 2855b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 2856b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 2857b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 2858b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 2859b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 2860b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 2861b8021494Sopenharmony_ci __ Fmov(d27, -0.2); 2862b8021494Sopenharmony_ci 2863b8021494Sopenharmony_ci __ Frinta(d12, d16); 2864b8021494Sopenharmony_ci __ Frinta(d13, d17); 2865b8021494Sopenharmony_ci __ Frinta(d14, d18); 2866b8021494Sopenharmony_ci __ Frinta(d15, d19); 2867b8021494Sopenharmony_ci __ Frinta(d16, d20); 2868b8021494Sopenharmony_ci __ Frinta(d17, d21); 2869b8021494Sopenharmony_ci __ Frinta(d18, d22); 2870b8021494Sopenharmony_ci __ Frinta(d19, d23); 2871b8021494Sopenharmony_ci __ Frinta(d20, d24); 2872b8021494Sopenharmony_ci __ Frinta(d21, d25); 2873b8021494Sopenharmony_ci __ Frinta(d22, d26); 2874b8021494Sopenharmony_ci __ Frinta(d23, d27); 2875b8021494Sopenharmony_ci END(); 2876b8021494Sopenharmony_ci 2877b8021494Sopenharmony_ci if (CAN_RUN()) { 2878b8021494Sopenharmony_ci RUN(); 2879b8021494Sopenharmony_ci 2880b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2881b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2882b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s2); 2883b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s3); 2884b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.0, s4); 2885b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s5); 2886b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-3.0, s6); 2887b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 2888b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 2889b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 2890b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 2891b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 2892b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d12); 2893b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d13); 2894b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d14); 2895b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d15); 2896b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.0, d16); 2897b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d17); 2898b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-3.0, d18); 2899b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d19); 2900b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d20); 2901b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d21); 2902b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d22); 2903b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d23); 2904b8021494Sopenharmony_ci } 2905b8021494Sopenharmony_ci} 2906b8021494Sopenharmony_ci 2907b8021494Sopenharmony_ci 2908b8021494Sopenharmony_ciTEST(frinti) { 2909b8021494Sopenharmony_ci // VIXL only supports the round-to-nearest FPCR mode, so this test has the 2910b8021494Sopenharmony_ci // same results as frintn. 2911b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 2912b8021494Sopenharmony_ci 2913b8021494Sopenharmony_ci START(); 2914b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 2915b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 2916b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 2917b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 2918b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 2919b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 2920b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 2921b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 2922b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 2923b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 2924b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 2925b8021494Sopenharmony_ci __ Fmov(s27, -0.2); 2926b8021494Sopenharmony_ci 2927b8021494Sopenharmony_ci __ Frinti(s0, s16); 2928b8021494Sopenharmony_ci __ Frinti(s1, s17); 2929b8021494Sopenharmony_ci __ Frinti(s2, s18); 2930b8021494Sopenharmony_ci __ Frinti(s3, s19); 2931b8021494Sopenharmony_ci __ Frinti(s4, s20); 2932b8021494Sopenharmony_ci __ Frinti(s5, s21); 2933b8021494Sopenharmony_ci __ Frinti(s6, s22); 2934b8021494Sopenharmony_ci __ Frinti(s7, s23); 2935b8021494Sopenharmony_ci __ Frinti(s8, s24); 2936b8021494Sopenharmony_ci __ Frinti(s9, s25); 2937b8021494Sopenharmony_ci __ Frinti(s10, s26); 2938b8021494Sopenharmony_ci __ Frinti(s11, s27); 2939b8021494Sopenharmony_ci 2940b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 2941b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 2942b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 2943b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 2944b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 2945b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 2946b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 2947b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 2948b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 2949b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 2950b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 2951b8021494Sopenharmony_ci __ Fmov(d27, -0.2); 2952b8021494Sopenharmony_ci 2953b8021494Sopenharmony_ci __ Frinti(d12, d16); 2954b8021494Sopenharmony_ci __ Frinti(d13, d17); 2955b8021494Sopenharmony_ci __ Frinti(d14, d18); 2956b8021494Sopenharmony_ci __ Frinti(d15, d19); 2957b8021494Sopenharmony_ci __ Frinti(d16, d20); 2958b8021494Sopenharmony_ci __ Frinti(d17, d21); 2959b8021494Sopenharmony_ci __ Frinti(d18, d22); 2960b8021494Sopenharmony_ci __ Frinti(d19, d23); 2961b8021494Sopenharmony_ci __ Frinti(d20, d24); 2962b8021494Sopenharmony_ci __ Frinti(d21, d25); 2963b8021494Sopenharmony_ci __ Frinti(d22, d26); 2964b8021494Sopenharmony_ci __ Frinti(d23, d27); 2965b8021494Sopenharmony_ci END(); 2966b8021494Sopenharmony_ci 2967b8021494Sopenharmony_ci if (CAN_RUN()) { 2968b8021494Sopenharmony_ci RUN(); 2969b8021494Sopenharmony_ci 2970b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 2971b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 2972b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s2); 2973b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s3); 2974b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 2975b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s5); 2976b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 2977b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 2978b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 2979b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 2980b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 2981b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 2982b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d12); 2983b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d13); 2984b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d14); 2985b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d15); 2986b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d16); 2987b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d17); 2988b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d18); 2989b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d19); 2990b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d20); 2991b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d21); 2992b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d22); 2993b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d23); 2994b8021494Sopenharmony_ci } 2995b8021494Sopenharmony_ci} 2996b8021494Sopenharmony_ci 2997b8021494Sopenharmony_ci 2998b8021494Sopenharmony_ciTEST(frintm) { 2999b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3000b8021494Sopenharmony_ci 3001b8021494Sopenharmony_ci START(); 3002b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 3003b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3004b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 3005b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 3006b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 3007b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 3008b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 3009b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 3010b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 3011b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 3012b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 3013b8021494Sopenharmony_ci __ Fmov(s27, -0.2); 3014b8021494Sopenharmony_ci 3015b8021494Sopenharmony_ci __ Frintm(s0, s16); 3016b8021494Sopenharmony_ci __ Frintm(s1, s17); 3017b8021494Sopenharmony_ci __ Frintm(s2, s18); 3018b8021494Sopenharmony_ci __ Frintm(s3, s19); 3019b8021494Sopenharmony_ci __ Frintm(s4, s20); 3020b8021494Sopenharmony_ci __ Frintm(s5, s21); 3021b8021494Sopenharmony_ci __ Frintm(s6, s22); 3022b8021494Sopenharmony_ci __ Frintm(s7, s23); 3023b8021494Sopenharmony_ci __ Frintm(s8, s24); 3024b8021494Sopenharmony_ci __ Frintm(s9, s25); 3025b8021494Sopenharmony_ci __ Frintm(s10, s26); 3026b8021494Sopenharmony_ci __ Frintm(s11, s27); 3027b8021494Sopenharmony_ci 3028b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 3029b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 3030b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 3031b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 3032b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 3033b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 3034b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 3035b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 3036b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 3037b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 3038b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 3039b8021494Sopenharmony_ci __ Fmov(d27, -0.2); 3040b8021494Sopenharmony_ci 3041b8021494Sopenharmony_ci __ Frintm(d12, d16); 3042b8021494Sopenharmony_ci __ Frintm(d13, d17); 3043b8021494Sopenharmony_ci __ Frintm(d14, d18); 3044b8021494Sopenharmony_ci __ Frintm(d15, d19); 3045b8021494Sopenharmony_ci __ Frintm(d16, d20); 3046b8021494Sopenharmony_ci __ Frintm(d17, d21); 3047b8021494Sopenharmony_ci __ Frintm(d18, d22); 3048b8021494Sopenharmony_ci __ Frintm(d19, d23); 3049b8021494Sopenharmony_ci __ Frintm(d20, d24); 3050b8021494Sopenharmony_ci __ Frintm(d21, d25); 3051b8021494Sopenharmony_ci __ Frintm(d22, d26); 3052b8021494Sopenharmony_ci __ Frintm(d23, d27); 3053b8021494Sopenharmony_ci END(); 3054b8021494Sopenharmony_ci 3055b8021494Sopenharmony_ci if (CAN_RUN()) { 3056b8021494Sopenharmony_ci RUN(); 3057b8021494Sopenharmony_ci 3058b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 3059b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 3060b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s2); 3061b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s3); 3062b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 3063b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s5); 3064b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-3.0, s6); 3065b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 3066b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 3067b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 3068b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 3069b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.0, s11); 3070b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d12); 3071b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d13); 3072b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d14); 3073b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d15); 3074b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d16); 3075b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d17); 3076b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-3.0, d18); 3077b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d19); 3078b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d20); 3079b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d21); 3080b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d22); 3081b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.0, d23); 3082b8021494Sopenharmony_ci } 3083b8021494Sopenharmony_ci} 3084b8021494Sopenharmony_ci 3085b8021494Sopenharmony_ci 3086b8021494Sopenharmony_ciTEST(frintn) { 3087b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3088b8021494Sopenharmony_ci 3089b8021494Sopenharmony_ci START(); 3090b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 3091b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3092b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 3093b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 3094b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 3095b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 3096b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 3097b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 3098b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 3099b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 3100b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 3101b8021494Sopenharmony_ci __ Fmov(s27, -0.2); 3102b8021494Sopenharmony_ci 3103b8021494Sopenharmony_ci __ Frintn(s0, s16); 3104b8021494Sopenharmony_ci __ Frintn(s1, s17); 3105b8021494Sopenharmony_ci __ Frintn(s2, s18); 3106b8021494Sopenharmony_ci __ Frintn(s3, s19); 3107b8021494Sopenharmony_ci __ Frintn(s4, s20); 3108b8021494Sopenharmony_ci __ Frintn(s5, s21); 3109b8021494Sopenharmony_ci __ Frintn(s6, s22); 3110b8021494Sopenharmony_ci __ Frintn(s7, s23); 3111b8021494Sopenharmony_ci __ Frintn(s8, s24); 3112b8021494Sopenharmony_ci __ Frintn(s9, s25); 3113b8021494Sopenharmony_ci __ Frintn(s10, s26); 3114b8021494Sopenharmony_ci __ Frintn(s11, s27); 3115b8021494Sopenharmony_ci 3116b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 3117b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 3118b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 3119b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 3120b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 3121b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 3122b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 3123b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 3124b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 3125b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 3126b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 3127b8021494Sopenharmony_ci __ Fmov(d27, -0.2); 3128b8021494Sopenharmony_ci 3129b8021494Sopenharmony_ci __ Frintn(d12, d16); 3130b8021494Sopenharmony_ci __ Frintn(d13, d17); 3131b8021494Sopenharmony_ci __ Frintn(d14, d18); 3132b8021494Sopenharmony_ci __ Frintn(d15, d19); 3133b8021494Sopenharmony_ci __ Frintn(d16, d20); 3134b8021494Sopenharmony_ci __ Frintn(d17, d21); 3135b8021494Sopenharmony_ci __ Frintn(d18, d22); 3136b8021494Sopenharmony_ci __ Frintn(d19, d23); 3137b8021494Sopenharmony_ci __ Frintn(d20, d24); 3138b8021494Sopenharmony_ci __ Frintn(d21, d25); 3139b8021494Sopenharmony_ci __ Frintn(d22, d26); 3140b8021494Sopenharmony_ci __ Frintn(d23, d27); 3141b8021494Sopenharmony_ci END(); 3142b8021494Sopenharmony_ci 3143b8021494Sopenharmony_ci if (CAN_RUN()) { 3144b8021494Sopenharmony_ci RUN(); 3145b8021494Sopenharmony_ci 3146b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 3147b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 3148b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s2); 3149b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s3); 3150b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 3151b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s5); 3152b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 3153b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 3154b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 3155b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 3156b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 3157b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 3158b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d12); 3159b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d13); 3160b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d14); 3161b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d15); 3162b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d16); 3163b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d17); 3164b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d18); 3165b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d19); 3166b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d20); 3167b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d21); 3168b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d22); 3169b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d23); 3170b8021494Sopenharmony_ci } 3171b8021494Sopenharmony_ci} 3172b8021494Sopenharmony_ci 3173b8021494Sopenharmony_ci 3174b8021494Sopenharmony_ciTEST(frintp) { 3175b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3176b8021494Sopenharmony_ci 3177b8021494Sopenharmony_ci START(); 3178b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 3179b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3180b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 3181b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 3182b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 3183b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 3184b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 3185b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 3186b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 3187b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 3188b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 3189b8021494Sopenharmony_ci __ Fmov(s27, -0.2); 3190b8021494Sopenharmony_ci 3191b8021494Sopenharmony_ci __ Frintp(s0, s16); 3192b8021494Sopenharmony_ci __ Frintp(s1, s17); 3193b8021494Sopenharmony_ci __ Frintp(s2, s18); 3194b8021494Sopenharmony_ci __ Frintp(s3, s19); 3195b8021494Sopenharmony_ci __ Frintp(s4, s20); 3196b8021494Sopenharmony_ci __ Frintp(s5, s21); 3197b8021494Sopenharmony_ci __ Frintp(s6, s22); 3198b8021494Sopenharmony_ci __ Frintp(s7, s23); 3199b8021494Sopenharmony_ci __ Frintp(s8, s24); 3200b8021494Sopenharmony_ci __ Frintp(s9, s25); 3201b8021494Sopenharmony_ci __ Frintp(s10, s26); 3202b8021494Sopenharmony_ci __ Frintp(s11, s27); 3203b8021494Sopenharmony_ci 3204b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 3205b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 3206b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 3207b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 3208b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 3209b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 3210b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 3211b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 3212b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 3213b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 3214b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 3215b8021494Sopenharmony_ci __ Fmov(d27, -0.2); 3216b8021494Sopenharmony_ci 3217b8021494Sopenharmony_ci __ Frintp(d12, d16); 3218b8021494Sopenharmony_ci __ Frintp(d13, d17); 3219b8021494Sopenharmony_ci __ Frintp(d14, d18); 3220b8021494Sopenharmony_ci __ Frintp(d15, d19); 3221b8021494Sopenharmony_ci __ Frintp(d16, d20); 3222b8021494Sopenharmony_ci __ Frintp(d17, d21); 3223b8021494Sopenharmony_ci __ Frintp(d18, d22); 3224b8021494Sopenharmony_ci __ Frintp(d19, d23); 3225b8021494Sopenharmony_ci __ Frintp(d20, d24); 3226b8021494Sopenharmony_ci __ Frintp(d21, d25); 3227b8021494Sopenharmony_ci __ Frintp(d22, d26); 3228b8021494Sopenharmony_ci __ Frintp(d23, d27); 3229b8021494Sopenharmony_ci END(); 3230b8021494Sopenharmony_ci 3231b8021494Sopenharmony_ci if (CAN_RUN()) { 3232b8021494Sopenharmony_ci RUN(); 3233b8021494Sopenharmony_ci 3234b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 3235b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s1); 3236b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s2); 3237b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s3); 3238b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(3.0, s4); 3239b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.0, s5); 3240b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 3241b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 3242b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 3243b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 3244b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 3245b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 3246b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d12); 3247b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d13); 3248b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d14); 3249b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d15); 3250b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(3.0, d16); 3251b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.0, d17); 3252b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d18); 3253b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d19); 3254b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d20); 3255b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d21); 3256b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d22); 3257b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d23); 3258b8021494Sopenharmony_ci } 3259b8021494Sopenharmony_ci} 3260b8021494Sopenharmony_ci 3261b8021494Sopenharmony_ci 3262b8021494Sopenharmony_ciTEST(frintx) { 3263b8021494Sopenharmony_ci // VIXL only supports the round-to-nearest FPCR mode, and it doesn't support 3264b8021494Sopenharmony_ci // FP exceptions, so this test has the same results as frintn (and frinti). 3265b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3266b8021494Sopenharmony_ci 3267b8021494Sopenharmony_ci START(); 3268b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 3269b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3270b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 3271b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 3272b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 3273b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 3274b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 3275b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 3276b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 3277b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 3278b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 3279b8021494Sopenharmony_ci __ Fmov(s27, -0.2); 3280b8021494Sopenharmony_ci 3281b8021494Sopenharmony_ci __ Frintx(s0, s16); 3282b8021494Sopenharmony_ci __ Frintx(s1, s17); 3283b8021494Sopenharmony_ci __ Frintx(s2, s18); 3284b8021494Sopenharmony_ci __ Frintx(s3, s19); 3285b8021494Sopenharmony_ci __ Frintx(s4, s20); 3286b8021494Sopenharmony_ci __ Frintx(s5, s21); 3287b8021494Sopenharmony_ci __ Frintx(s6, s22); 3288b8021494Sopenharmony_ci __ Frintx(s7, s23); 3289b8021494Sopenharmony_ci __ Frintx(s8, s24); 3290b8021494Sopenharmony_ci __ Frintx(s9, s25); 3291b8021494Sopenharmony_ci __ Frintx(s10, s26); 3292b8021494Sopenharmony_ci __ Frintx(s11, s27); 3293b8021494Sopenharmony_ci 3294b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 3295b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 3296b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 3297b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 3298b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 3299b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 3300b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 3301b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 3302b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 3303b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 3304b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 3305b8021494Sopenharmony_ci __ Fmov(d27, -0.2); 3306b8021494Sopenharmony_ci 3307b8021494Sopenharmony_ci __ Frintx(d12, d16); 3308b8021494Sopenharmony_ci __ Frintx(d13, d17); 3309b8021494Sopenharmony_ci __ Frintx(d14, d18); 3310b8021494Sopenharmony_ci __ Frintx(d15, d19); 3311b8021494Sopenharmony_ci __ Frintx(d16, d20); 3312b8021494Sopenharmony_ci __ Frintx(d17, d21); 3313b8021494Sopenharmony_ci __ Frintx(d18, d22); 3314b8021494Sopenharmony_ci __ Frintx(d19, d23); 3315b8021494Sopenharmony_ci __ Frintx(d20, d24); 3316b8021494Sopenharmony_ci __ Frintx(d21, d25); 3317b8021494Sopenharmony_ci __ Frintx(d22, d26); 3318b8021494Sopenharmony_ci __ Frintx(d23, d27); 3319b8021494Sopenharmony_ci END(); 3320b8021494Sopenharmony_ci 3321b8021494Sopenharmony_ci if (CAN_RUN()) { 3322b8021494Sopenharmony_ci RUN(); 3323b8021494Sopenharmony_ci 3324b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 3325b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 3326b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s2); 3327b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s3); 3328b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 3329b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s5); 3330b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 3331b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 3332b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 3333b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 3334b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 3335b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s11); 3336b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d12); 3337b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d13); 3338b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d14); 3339b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d15); 3340b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d16); 3341b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d17); 3342b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d18); 3343b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d19); 3344b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d20); 3345b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d21); 3346b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d22); 3347b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d23); 3348b8021494Sopenharmony_ci } 3349b8021494Sopenharmony_ci} 3350b8021494Sopenharmony_ci 3351b8021494Sopenharmony_ci 3352b8021494Sopenharmony_ciTEST(frintz) { 3353b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3354b8021494Sopenharmony_ci 3355b8021494Sopenharmony_ci START(); 3356b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 3357b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3358b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 3359b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 3360b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 3361b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 3362b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 3363b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 3364b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 3365b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 3366b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 3367b8021494Sopenharmony_ci 3368b8021494Sopenharmony_ci __ Frintz(s0, s16); 3369b8021494Sopenharmony_ci __ Frintz(s1, s17); 3370b8021494Sopenharmony_ci __ Frintz(s2, s18); 3371b8021494Sopenharmony_ci __ Frintz(s3, s19); 3372b8021494Sopenharmony_ci __ Frintz(s4, s20); 3373b8021494Sopenharmony_ci __ Frintz(s5, s21); 3374b8021494Sopenharmony_ci __ Frintz(s6, s22); 3375b8021494Sopenharmony_ci __ Frintz(s7, s23); 3376b8021494Sopenharmony_ci __ Frintz(s8, s24); 3377b8021494Sopenharmony_ci __ Frintz(s9, s25); 3378b8021494Sopenharmony_ci __ Frintz(s10, s26); 3379b8021494Sopenharmony_ci 3380b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 3381b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 3382b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 3383b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 3384b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 3385b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 3386b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 3387b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 3388b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 3389b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 3390b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 3391b8021494Sopenharmony_ci 3392b8021494Sopenharmony_ci __ Frintz(d11, d16); 3393b8021494Sopenharmony_ci __ Frintz(d12, d17); 3394b8021494Sopenharmony_ci __ Frintz(d13, d18); 3395b8021494Sopenharmony_ci __ Frintz(d14, d19); 3396b8021494Sopenharmony_ci __ Frintz(d15, d20); 3397b8021494Sopenharmony_ci __ Frintz(d16, d21); 3398b8021494Sopenharmony_ci __ Frintz(d17, d22); 3399b8021494Sopenharmony_ci __ Frintz(d18, d23); 3400b8021494Sopenharmony_ci __ Frintz(d19, d24); 3401b8021494Sopenharmony_ci __ Frintz(d20, d25); 3402b8021494Sopenharmony_ci __ Frintz(d21, d26); 3403b8021494Sopenharmony_ci END(); 3404b8021494Sopenharmony_ci 3405b8021494Sopenharmony_ci if (CAN_RUN()) { 3406b8021494Sopenharmony_ci RUN(); 3407b8021494Sopenharmony_ci 3408b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s0); 3409b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s1); 3410b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s2); 3411b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0, s3); 3412b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.0, s4); 3413b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.0, s5); 3414b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.0, s6); 3415b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 3416b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 3417b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0, s9); 3418b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0, s10); 3419b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d11); 3420b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d12); 3421b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d13); 3422b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0, d14); 3423b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.0, d15); 3424b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.0, d16); 3425b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.0, d17); 3426b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d18); 3427b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d19); 3428b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0, d20); 3429b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0, d21); 3430b8021494Sopenharmony_ci } 3431b8021494Sopenharmony_ci} 3432b8021494Sopenharmony_ci 3433b8021494Sopenharmony_ci 3434b8021494Sopenharmony_ciTEST(fcvt_ds) { 3435b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3436b8021494Sopenharmony_ci 3437b8021494Sopenharmony_ci START(); 3438b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 3439b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3440b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 3441b8021494Sopenharmony_ci __ Fmov(s19, 1.9); 3442b8021494Sopenharmony_ci __ Fmov(s20, 2.5); 3443b8021494Sopenharmony_ci __ Fmov(s21, -1.5); 3444b8021494Sopenharmony_ci __ Fmov(s22, -2.5); 3445b8021494Sopenharmony_ci __ Fmov(s23, kFP32PositiveInfinity); 3446b8021494Sopenharmony_ci __ Fmov(s24, kFP32NegativeInfinity); 3447b8021494Sopenharmony_ci __ Fmov(s25, 0.0); 3448b8021494Sopenharmony_ci __ Fmov(s26, -0.0); 3449b8021494Sopenharmony_ci __ Fmov(s27, FLT_MAX); 3450b8021494Sopenharmony_ci __ Fmov(s28, FLT_MIN); 3451b8021494Sopenharmony_ci __ Fmov(s29, RawbitsToFloat(0x7fc12345)); // Quiet NaN. 3452b8021494Sopenharmony_ci __ Fmov(s30, RawbitsToFloat(0x7f812345)); // Signalling NaN. 3453b8021494Sopenharmony_ci 3454b8021494Sopenharmony_ci __ Fcvt(d0, s16); 3455b8021494Sopenharmony_ci __ Fcvt(d1, s17); 3456b8021494Sopenharmony_ci __ Fcvt(d2, s18); 3457b8021494Sopenharmony_ci __ Fcvt(d3, s19); 3458b8021494Sopenharmony_ci __ Fcvt(d4, s20); 3459b8021494Sopenharmony_ci __ Fcvt(d5, s21); 3460b8021494Sopenharmony_ci __ Fcvt(d6, s22); 3461b8021494Sopenharmony_ci __ Fcvt(d7, s23); 3462b8021494Sopenharmony_ci __ Fcvt(d8, s24); 3463b8021494Sopenharmony_ci __ Fcvt(d9, s25); 3464b8021494Sopenharmony_ci __ Fcvt(d10, s26); 3465b8021494Sopenharmony_ci __ Fcvt(d11, s27); 3466b8021494Sopenharmony_ci __ Fcvt(d12, s28); 3467b8021494Sopenharmony_ci __ Fcvt(d13, s29); 3468b8021494Sopenharmony_ci __ Fcvt(d14, s30); 3469b8021494Sopenharmony_ci END(); 3470b8021494Sopenharmony_ci 3471b8021494Sopenharmony_ci if (CAN_RUN()) { 3472b8021494Sopenharmony_ci RUN(); 3473b8021494Sopenharmony_ci 3474b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.0f, d0); 3475b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.1f, d1); 3476b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.5f, d2); 3477b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(1.9f, d3); 3478b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(2.5f, d4); 3479b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-1.5f, d5); 3480b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-2.5f, d6); 3481b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64PositiveInfinity, d7); 3482b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64NegativeInfinity, d8); 3483b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(0.0f, d9); 3484b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(-0.0f, d10); 3485b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(FLT_MAX, d11); 3486b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(FLT_MIN, d12); 3487b8021494Sopenharmony_ci 3488b8021494Sopenharmony_ci // Check that the NaN payload is preserved according to Aarch64 conversion 3489b8021494Sopenharmony_ci // rules: 3490b8021494Sopenharmony_ci // - The sign bit is preserved. 3491b8021494Sopenharmony_ci // - The top bit of the mantissa is forced to 1 (making it a quiet NaN). 3492b8021494Sopenharmony_ci // - The remaining mantissa bits are copied until they run out. 3493b8021494Sopenharmony_ci // - The low-order bits that haven't already been assigned are set to 0. 3494b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(0x7ff82468a0000000), d13); 3495b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(0x7ff82468a0000000), d14); 3496b8021494Sopenharmony_ci } 3497b8021494Sopenharmony_ci} 3498b8021494Sopenharmony_ci 3499b8021494Sopenharmony_ci 3500b8021494Sopenharmony_ciTEST(fcvt_sd) { 3501b8021494Sopenharmony_ci // Test simple conversions here. Complex behaviour (such as rounding 3502b8021494Sopenharmony_ci // specifics) are tested in the simulator tests. 3503b8021494Sopenharmony_ci 3504b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3505b8021494Sopenharmony_ci 3506b8021494Sopenharmony_ci START(); 3507b8021494Sopenharmony_ci __ Fmov(d16, 1.0); 3508b8021494Sopenharmony_ci __ Fmov(d17, 1.1); 3509b8021494Sopenharmony_ci __ Fmov(d18, 1.5); 3510b8021494Sopenharmony_ci __ Fmov(d19, 1.9); 3511b8021494Sopenharmony_ci __ Fmov(d20, 2.5); 3512b8021494Sopenharmony_ci __ Fmov(d21, -1.5); 3513b8021494Sopenharmony_ci __ Fmov(d22, -2.5); 3514b8021494Sopenharmony_ci __ Fmov(d23, kFP32PositiveInfinity); 3515b8021494Sopenharmony_ci __ Fmov(d24, kFP32NegativeInfinity); 3516b8021494Sopenharmony_ci __ Fmov(d25, 0.0); 3517b8021494Sopenharmony_ci __ Fmov(d26, -0.0); 3518b8021494Sopenharmony_ci __ Fmov(d27, FLT_MAX); 3519b8021494Sopenharmony_ci __ Fmov(d28, FLT_MIN); 3520b8021494Sopenharmony_ci __ Fmov(d29, RawbitsToDouble(0x7ff82468a0000000)); // Quiet NaN. 3521b8021494Sopenharmony_ci __ Fmov(d30, RawbitsToDouble(0x7ff02468a0000000)); // Signalling NaN. 3522b8021494Sopenharmony_ci 3523b8021494Sopenharmony_ci __ Fcvt(s0, d16); 3524b8021494Sopenharmony_ci __ Fcvt(s1, d17); 3525b8021494Sopenharmony_ci __ Fcvt(s2, d18); 3526b8021494Sopenharmony_ci __ Fcvt(s3, d19); 3527b8021494Sopenharmony_ci __ Fcvt(s4, d20); 3528b8021494Sopenharmony_ci __ Fcvt(s5, d21); 3529b8021494Sopenharmony_ci __ Fcvt(s6, d22); 3530b8021494Sopenharmony_ci __ Fcvt(s7, d23); 3531b8021494Sopenharmony_ci __ Fcvt(s8, d24); 3532b8021494Sopenharmony_ci __ Fcvt(s9, d25); 3533b8021494Sopenharmony_ci __ Fcvt(s10, d26); 3534b8021494Sopenharmony_ci __ Fcvt(s11, d27); 3535b8021494Sopenharmony_ci __ Fcvt(s12, d28); 3536b8021494Sopenharmony_ci __ Fcvt(s13, d29); 3537b8021494Sopenharmony_ci __ Fcvt(s14, d30); 3538b8021494Sopenharmony_ci END(); 3539b8021494Sopenharmony_ci 3540b8021494Sopenharmony_ci if (CAN_RUN()) { 3541b8021494Sopenharmony_ci RUN(); 3542b8021494Sopenharmony_ci 3543b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.0f, s0); 3544b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.1f, s1); 3545b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.5f, s2); 3546b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(1.9f, s3); 3547b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(2.5f, s4); 3548b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-1.5f, s5); 3549b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-2.5f, s6); 3550b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32PositiveInfinity, s7); 3551b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32NegativeInfinity, s8); 3552b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(0.0f, s9); 3553b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(-0.0f, s10); 3554b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(FLT_MAX, s11); 3555b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(FLT_MIN, s12); 3556b8021494Sopenharmony_ci 3557b8021494Sopenharmony_ci // Check that the NaN payload is preserved according to Aarch64 conversion 3558b8021494Sopenharmony_ci // rules: 3559b8021494Sopenharmony_ci // - The sign bit is preserved. 3560b8021494Sopenharmony_ci // - The top bit of the mantissa is forced to 1 (making it a quiet NaN). 3561b8021494Sopenharmony_ci // - The remaining mantissa bits are copied until they run out. 3562b8021494Sopenharmony_ci // - The low-order bits that haven't already been assigned are set to 0. 3563b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(0x7fc12345), s13); 3564b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(0x7fc12345), s14); 3565b8021494Sopenharmony_ci } 3566b8021494Sopenharmony_ci} 3567b8021494Sopenharmony_ci 3568b8021494Sopenharmony_ci 3569b8021494Sopenharmony_ciTEST(fcvt_half) { 3570b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3571b8021494Sopenharmony_ci 3572b8021494Sopenharmony_ci START(); 3573b8021494Sopenharmony_ci Label done; 3574b8021494Sopenharmony_ci { 3575b8021494Sopenharmony_ci // Check all exact conversions from half to float and back. 3576b8021494Sopenharmony_ci Label ok, fail; 3577b8021494Sopenharmony_ci __ Mov(w0, 0); 3578b8021494Sopenharmony_ci for (int i = 0; i < 0xffff; i += 3) { 3579b8021494Sopenharmony_ci if ((i & 0x7c00) == 0x7c00) continue; 3580b8021494Sopenharmony_ci __ Mov(w1, i); 3581b8021494Sopenharmony_ci __ Fmov(s1, w1); 3582b8021494Sopenharmony_ci __ Fcvt(s2, h1); 3583b8021494Sopenharmony_ci __ Fcvt(h2, s2); 3584b8021494Sopenharmony_ci __ Fmov(w2, s2); 3585b8021494Sopenharmony_ci __ Cmp(w1, w2); 3586b8021494Sopenharmony_ci __ B(&fail, ne); 3587b8021494Sopenharmony_ci } 3588b8021494Sopenharmony_ci __ B(&ok); 3589b8021494Sopenharmony_ci __ Bind(&fail); 3590b8021494Sopenharmony_ci __ Mov(w0, 1); 3591b8021494Sopenharmony_ci __ B(&done); 3592b8021494Sopenharmony_ci __ Bind(&ok); 3593b8021494Sopenharmony_ci } 3594b8021494Sopenharmony_ci { 3595b8021494Sopenharmony_ci // Check all exact conversions from half to double and back. 3596b8021494Sopenharmony_ci Label ok, fail; 3597b8021494Sopenharmony_ci for (int i = 0; i < 0xffff; i += 3) { 3598b8021494Sopenharmony_ci if ((i & 0x7c00) == 0x7c00) continue; 3599b8021494Sopenharmony_ci __ Mov(w1, i); 3600b8021494Sopenharmony_ci __ Fmov(s1, w1); 3601b8021494Sopenharmony_ci __ Fcvt(d2, h1); 3602b8021494Sopenharmony_ci __ Fcvt(h2, d2); 3603b8021494Sopenharmony_ci __ Fmov(w2, s2); 3604b8021494Sopenharmony_ci __ Cmp(w1, w2); 3605b8021494Sopenharmony_ci __ B(&fail, ne); 3606b8021494Sopenharmony_ci } 3607b8021494Sopenharmony_ci __ B(&ok); 3608b8021494Sopenharmony_ci __ Bind(&fail); 3609b8021494Sopenharmony_ci __ Mov(w0, 2); 3610b8021494Sopenharmony_ci __ Bind(&ok); 3611b8021494Sopenharmony_ci } 3612b8021494Sopenharmony_ci __ Bind(&done); 3613b8021494Sopenharmony_ci 3614b8021494Sopenharmony_ci // Check some other interesting values. 3615b8021494Sopenharmony_ci __ Fmov(s0, kFP32PositiveInfinity); 3616b8021494Sopenharmony_ci __ Fmov(s1, kFP32NegativeInfinity); 3617b8021494Sopenharmony_ci __ Fmov(s2, 65504); // Max half precision. 3618b8021494Sopenharmony_ci __ Fmov(s3, 6.10352e-5); // Min positive normal. 3619b8021494Sopenharmony_ci __ Fmov(s4, 6.09756e-5); // Max subnormal. 3620b8021494Sopenharmony_ci __ Fmov(s5, 5.96046e-8); // Min positive subnormal. 3621b8021494Sopenharmony_ci __ Fmov(s6, 5e-9); // Not representable -> zero. 3622b8021494Sopenharmony_ci __ Fmov(s7, -0.0); 3623b8021494Sopenharmony_ci __ Fcvt(h0, s0); 3624b8021494Sopenharmony_ci __ Fcvt(h1, s1); 3625b8021494Sopenharmony_ci __ Fcvt(h2, s2); 3626b8021494Sopenharmony_ci __ Fcvt(h3, s3); 3627b8021494Sopenharmony_ci __ Fcvt(h4, s4); 3628b8021494Sopenharmony_ci __ Fcvt(h5, s5); 3629b8021494Sopenharmony_ci __ Fcvt(h6, s6); 3630b8021494Sopenharmony_ci __ Fcvt(h7, s7); 3631b8021494Sopenharmony_ci 3632b8021494Sopenharmony_ci __ Fmov(d20, kFP64PositiveInfinity); 3633b8021494Sopenharmony_ci __ Fmov(d21, kFP64NegativeInfinity); 3634b8021494Sopenharmony_ci __ Fmov(d22, 65504); // Max half precision. 3635b8021494Sopenharmony_ci __ Fmov(d23, 6.10352e-5); // Min positive normal. 3636b8021494Sopenharmony_ci __ Fmov(d24, 6.09756e-5); // Max subnormal. 3637b8021494Sopenharmony_ci __ Fmov(d25, 5.96046e-8); // Min positive subnormal. 3638b8021494Sopenharmony_ci __ Fmov(d26, 5e-9); // Not representable -> zero. 3639b8021494Sopenharmony_ci __ Fmov(d27, -0.0); 3640b8021494Sopenharmony_ci __ Fcvt(h20, d20); 3641b8021494Sopenharmony_ci __ Fcvt(h21, d21); 3642b8021494Sopenharmony_ci __ Fcvt(h22, d22); 3643b8021494Sopenharmony_ci __ Fcvt(h23, d23); 3644b8021494Sopenharmony_ci __ Fcvt(h24, d24); 3645b8021494Sopenharmony_ci __ Fcvt(h25, d25); 3646b8021494Sopenharmony_ci __ Fcvt(h26, d26); 3647b8021494Sopenharmony_ci __ Fcvt(h27, d27); 3648b8021494Sopenharmony_ci END(); 3649b8021494Sopenharmony_ci 3650b8021494Sopenharmony_ci if (CAN_RUN()) { 3651b8021494Sopenharmony_ci RUN(); 3652b8021494Sopenharmony_ci 3653b8021494Sopenharmony_ci ASSERT_EQUAL_32(0, w0); // 1 => float failed, 2 => double failed. 3654b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, Float16ToRawbits(kFP16PositiveInfinity), q0); 3655b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, Float16ToRawbits(kFP16NegativeInfinity), q1); 3656b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x7bff, q2); 3657b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x0400, q3); 3658b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x03ff, q4); 3659b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x0001, q5); 3660b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0, q6); 3661b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x8000, q7); 3662b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, Float16ToRawbits(kFP16PositiveInfinity), q20); 3663b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, Float16ToRawbits(kFP16NegativeInfinity), q21); 3664b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x7bff, q22); 3665b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x0400, q23); 3666b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x03ff, q24); 3667b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x0001, q25); 3668b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0, q26); 3669b8021494Sopenharmony_ci ASSERT_EQUAL_128(0, 0x8000, q27); 3670b8021494Sopenharmony_ci } 3671b8021494Sopenharmony_ci} 3672b8021494Sopenharmony_ci 3673b8021494Sopenharmony_ci 3674b8021494Sopenharmony_ciTEST(fcvtas) { 3675b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3676b8021494Sopenharmony_ci 3677b8021494Sopenharmony_ci START(); 3678b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 3679b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 3680b8021494Sopenharmony_ci __ Fmov(s2, 2.5); 3681b8021494Sopenharmony_ci __ Fmov(s3, -2.5); 3682b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 3683b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 3684b8021494Sopenharmony_ci __ Fmov(s6, 0x7fffff80); // Largest float < INT32_MAX. 3685b8021494Sopenharmony_ci __ Fneg(s7, s6); // Smallest float > INT32_MIN. 3686b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 3687b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 3688b8021494Sopenharmony_ci __ Fmov(d10, 2.5); 3689b8021494Sopenharmony_ci __ Fmov(d11, -2.5); 3690b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 3691b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 3692b8021494Sopenharmony_ci __ Fmov(d14, kWMaxInt - 1); 3693b8021494Sopenharmony_ci __ Fmov(d15, kWMinInt + 1); 3694b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3695b8021494Sopenharmony_ci __ Fmov(s18, 2.5); 3696b8021494Sopenharmony_ci __ Fmov(s19, -2.5); 3697b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 3698b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 3699b8021494Sopenharmony_ci __ Fmov(s22, 0x7fffff8000000000); // Largest float < INT64_MAX. 3700b8021494Sopenharmony_ci __ Fneg(s23, s22); // Smallest float > INT64_MIN. 3701b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 3702b8021494Sopenharmony_ci __ Fmov(d25, 2.5); 3703b8021494Sopenharmony_ci __ Fmov(d26, -2.5); 3704b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 3705b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 3706b8021494Sopenharmony_ci __ Fmov(d29, 0x7ffffffffffffc00); // Largest double < INT64_MAX. 3707b8021494Sopenharmony_ci __ Fneg(d30, d29); // Smallest double > INT64_MIN. 3708b8021494Sopenharmony_ci 3709b8021494Sopenharmony_ci __ Fcvtas(w0, s0); 3710b8021494Sopenharmony_ci __ Fcvtas(w1, s1); 3711b8021494Sopenharmony_ci __ Fcvtas(w2, s2); 3712b8021494Sopenharmony_ci __ Fcvtas(w3, s3); 3713b8021494Sopenharmony_ci __ Fcvtas(w4, s4); 3714b8021494Sopenharmony_ci __ Fcvtas(w5, s5); 3715b8021494Sopenharmony_ci __ Fcvtas(w6, s6); 3716b8021494Sopenharmony_ci __ Fcvtas(w7, s7); 3717b8021494Sopenharmony_ci __ Fcvtas(w8, d8); 3718b8021494Sopenharmony_ci __ Fcvtas(w9, d9); 3719b8021494Sopenharmony_ci __ Fcvtas(w10, d10); 3720b8021494Sopenharmony_ci __ Fcvtas(w11, d11); 3721b8021494Sopenharmony_ci __ Fcvtas(w12, d12); 3722b8021494Sopenharmony_ci __ Fcvtas(w13, d13); 3723b8021494Sopenharmony_ci __ Fcvtas(w14, d14); 3724b8021494Sopenharmony_ci __ Fcvtas(w15, d15); 3725b8021494Sopenharmony_ci __ Fcvtas(x17, s17); 3726b8021494Sopenharmony_ci __ Fcvtas(x18, s18); 3727b8021494Sopenharmony_ci __ Fcvtas(x19, s19); 3728b8021494Sopenharmony_ci __ Fcvtas(x20, s20); 3729b8021494Sopenharmony_ci __ Fcvtas(x21, s21); 3730b8021494Sopenharmony_ci __ Fcvtas(x22, s22); 3731b8021494Sopenharmony_ci __ Fcvtas(x23, s23); 3732b8021494Sopenharmony_ci __ Fcvtas(x24, d24); 3733b8021494Sopenharmony_ci __ Fcvtas(x25, d25); 3734b8021494Sopenharmony_ci __ Fcvtas(x26, d26); 3735b8021494Sopenharmony_ci __ Fcvtas(x27, d27); 3736b8021494Sopenharmony_ci __ Fcvtas(x28, d28); 3737b8021494Sopenharmony_ci __ Fcvtas(x29, d29); 3738b8021494Sopenharmony_ci __ Fcvtas(x30, d30); 3739b8021494Sopenharmony_ci END(); 3740b8021494Sopenharmony_ci 3741b8021494Sopenharmony_ci if (CAN_RUN()) { 3742b8021494Sopenharmony_ci RUN(); 3743b8021494Sopenharmony_ci 3744b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 3745b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 3746b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x2); 3747b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffd, x3); 3748b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x4); 3749b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x5); 3750b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff80, x6); 3751b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000080, x7); 3752b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 3753b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 3754b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x10); 3755b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffd, x11); 3756b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x12); 3757b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x13); 3758b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffe, x14); 3759b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000001, x15); 3760b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 3761b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x18); 3762b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffffffd, x19); 3763b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x20); 3764b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x21); 3765b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff8000000000, x22); 3766b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000008000000000, x23); 3767b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 3768b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x25); 3769b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffffffd, x26); 3770b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x27); 3771b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x28); 3772b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffffffffc00, x29); 3773b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000400, x30); 3774b8021494Sopenharmony_ci } 3775b8021494Sopenharmony_ci} 3776b8021494Sopenharmony_ci 3777b8021494Sopenharmony_ci 3778b8021494Sopenharmony_ciTEST(fcvtau) { 3779b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3780b8021494Sopenharmony_ci 3781b8021494Sopenharmony_ci START(); 3782b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 3783b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 3784b8021494Sopenharmony_ci __ Fmov(s2, 2.5); 3785b8021494Sopenharmony_ci __ Fmov(s3, -2.5); 3786b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 3787b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 3788b8021494Sopenharmony_ci __ Fmov(s6, 0xffffff00); // Largest float < UINT32_MAX. 3789b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 3790b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 3791b8021494Sopenharmony_ci __ Fmov(d10, 2.5); 3792b8021494Sopenharmony_ci __ Fmov(d11, -2.5); 3793b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 3794b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 3795b8021494Sopenharmony_ci __ Fmov(d14, 0xfffffffe); 3796b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 3797b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3798b8021494Sopenharmony_ci __ Fmov(s18, 2.5); 3799b8021494Sopenharmony_ci __ Fmov(s19, -2.5); 3800b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 3801b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 3802b8021494Sopenharmony_ci __ Fmov(s22, 0xffffff0000000000); // Largest float < UINT64_MAX. 3803b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 3804b8021494Sopenharmony_ci __ Fmov(d25, 2.5); 3805b8021494Sopenharmony_ci __ Fmov(d26, -2.5); 3806b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 3807b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 3808b8021494Sopenharmony_ci __ Fmov(d29, 0xfffffffffffff800); // Largest double < UINT64_MAX. 3809b8021494Sopenharmony_ci __ Fmov(s30, 0x100000000); 3810b8021494Sopenharmony_ci 3811b8021494Sopenharmony_ci __ Fcvtau(w0, s0); 3812b8021494Sopenharmony_ci __ Fcvtau(w1, s1); 3813b8021494Sopenharmony_ci __ Fcvtau(w2, s2); 3814b8021494Sopenharmony_ci __ Fcvtau(w3, s3); 3815b8021494Sopenharmony_ci __ Fcvtau(w4, s4); 3816b8021494Sopenharmony_ci __ Fcvtau(w5, s5); 3817b8021494Sopenharmony_ci __ Fcvtau(w6, s6); 3818b8021494Sopenharmony_ci __ Fcvtau(w8, d8); 3819b8021494Sopenharmony_ci __ Fcvtau(w9, d9); 3820b8021494Sopenharmony_ci __ Fcvtau(w10, d10); 3821b8021494Sopenharmony_ci __ Fcvtau(w11, d11); 3822b8021494Sopenharmony_ci __ Fcvtau(w12, d12); 3823b8021494Sopenharmony_ci __ Fcvtau(w13, d13); 3824b8021494Sopenharmony_ci __ Fcvtau(w14, d14); 3825b8021494Sopenharmony_ci __ Fcvtau(w15, d15); 3826b8021494Sopenharmony_ci __ Fcvtau(x16, s16); 3827b8021494Sopenharmony_ci __ Fcvtau(x17, s17); 3828b8021494Sopenharmony_ci __ Fcvtau(x18, s18); 3829b8021494Sopenharmony_ci __ Fcvtau(x19, s19); 3830b8021494Sopenharmony_ci __ Fcvtau(x20, s20); 3831b8021494Sopenharmony_ci __ Fcvtau(x21, s21); 3832b8021494Sopenharmony_ci __ Fcvtau(x22, s22); 3833b8021494Sopenharmony_ci __ Fcvtau(x24, d24); 3834b8021494Sopenharmony_ci __ Fcvtau(x25, d25); 3835b8021494Sopenharmony_ci __ Fcvtau(x26, d26); 3836b8021494Sopenharmony_ci __ Fcvtau(x27, d27); 3837b8021494Sopenharmony_ci __ Fcvtau(x28, d28); 3838b8021494Sopenharmony_ci __ Fcvtau(x29, d29); 3839b8021494Sopenharmony_ci __ Fcvtau(w30, s30); 3840b8021494Sopenharmony_ci END(); 3841b8021494Sopenharmony_ci 3842b8021494Sopenharmony_ci if (CAN_RUN()) { 3843b8021494Sopenharmony_ci RUN(); 3844b8021494Sopenharmony_ci 3845b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 3846b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 3847b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x2); 3848b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x3); 3849b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x4); 3850b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x5); 3851b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffff00, x6); 3852b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 3853b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 3854b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x10); 3855b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x11); 3856b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x12); 3857b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x13); 3858b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffe, x14); 3859b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x16); 3860b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 3861b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x18); 3862b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x19); 3863b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x20); 3864b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x21); 3865b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffff0000000000, x22); 3866b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 3867b8021494Sopenharmony_ci ASSERT_EQUAL_64(3, x25); 3868b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x26); 3869b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x27); 3870b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x28); 3871b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffff800, x29); 3872b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x30); 3873b8021494Sopenharmony_ci } 3874b8021494Sopenharmony_ci} 3875b8021494Sopenharmony_ci 3876b8021494Sopenharmony_ci 3877b8021494Sopenharmony_ciTEST(fcvtms) { 3878b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3879b8021494Sopenharmony_ci 3880b8021494Sopenharmony_ci START(); 3881b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 3882b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 3883b8021494Sopenharmony_ci __ Fmov(s2, 1.5); 3884b8021494Sopenharmony_ci __ Fmov(s3, -1.5); 3885b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 3886b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 3887b8021494Sopenharmony_ci __ Fmov(s6, 0x7fffff80); // Largest float < INT32_MAX. 3888b8021494Sopenharmony_ci __ Fneg(s7, s6); // Smallest float > INT32_MIN. 3889b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 3890b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 3891b8021494Sopenharmony_ci __ Fmov(d10, 1.5); 3892b8021494Sopenharmony_ci __ Fmov(d11, -1.5); 3893b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 3894b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 3895b8021494Sopenharmony_ci __ Fmov(d14, kWMaxInt - 1); 3896b8021494Sopenharmony_ci __ Fmov(d15, kWMinInt + 1); 3897b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 3898b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 3899b8021494Sopenharmony_ci __ Fmov(s19, -1.5); 3900b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 3901b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 3902b8021494Sopenharmony_ci __ Fmov(s22, 0x7fffff8000000000); // Largest float < INT64_MAX. 3903b8021494Sopenharmony_ci __ Fneg(s23, s22); // Smallest float > INT64_MIN. 3904b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 3905b8021494Sopenharmony_ci __ Fmov(d25, 1.5); 3906b8021494Sopenharmony_ci __ Fmov(d26, -1.5); 3907b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 3908b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 3909b8021494Sopenharmony_ci __ Fmov(d29, 0x7ffffffffffffc00); // Largest double < INT64_MAX. 3910b8021494Sopenharmony_ci __ Fneg(d30, d29); // Smallest double > INT64_MIN. 3911b8021494Sopenharmony_ci 3912b8021494Sopenharmony_ci __ Fcvtms(w0, s0); 3913b8021494Sopenharmony_ci __ Fcvtms(w1, s1); 3914b8021494Sopenharmony_ci __ Fcvtms(w2, s2); 3915b8021494Sopenharmony_ci __ Fcvtms(w3, s3); 3916b8021494Sopenharmony_ci __ Fcvtms(w4, s4); 3917b8021494Sopenharmony_ci __ Fcvtms(w5, s5); 3918b8021494Sopenharmony_ci __ Fcvtms(w6, s6); 3919b8021494Sopenharmony_ci __ Fcvtms(w7, s7); 3920b8021494Sopenharmony_ci __ Fcvtms(w8, d8); 3921b8021494Sopenharmony_ci __ Fcvtms(w9, d9); 3922b8021494Sopenharmony_ci __ Fcvtms(w10, d10); 3923b8021494Sopenharmony_ci __ Fcvtms(w11, d11); 3924b8021494Sopenharmony_ci __ Fcvtms(w12, d12); 3925b8021494Sopenharmony_ci __ Fcvtms(w13, d13); 3926b8021494Sopenharmony_ci __ Fcvtms(w14, d14); 3927b8021494Sopenharmony_ci __ Fcvtms(w15, d15); 3928b8021494Sopenharmony_ci __ Fcvtms(x17, s17); 3929b8021494Sopenharmony_ci __ Fcvtms(x18, s18); 3930b8021494Sopenharmony_ci __ Fcvtms(x19, s19); 3931b8021494Sopenharmony_ci __ Fcvtms(x20, s20); 3932b8021494Sopenharmony_ci __ Fcvtms(x21, s21); 3933b8021494Sopenharmony_ci __ Fcvtms(x22, s22); 3934b8021494Sopenharmony_ci __ Fcvtms(x23, s23); 3935b8021494Sopenharmony_ci __ Fcvtms(x24, d24); 3936b8021494Sopenharmony_ci __ Fcvtms(x25, d25); 3937b8021494Sopenharmony_ci __ Fcvtms(x26, d26); 3938b8021494Sopenharmony_ci __ Fcvtms(x27, d27); 3939b8021494Sopenharmony_ci __ Fcvtms(x28, d28); 3940b8021494Sopenharmony_ci __ Fcvtms(x29, d29); 3941b8021494Sopenharmony_ci __ Fcvtms(x30, d30); 3942b8021494Sopenharmony_ci END(); 3943b8021494Sopenharmony_ci 3944b8021494Sopenharmony_ci if (CAN_RUN()) { 3945b8021494Sopenharmony_ci RUN(); 3946b8021494Sopenharmony_ci 3947b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 3948b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 3949b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x2); 3950b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffe, x3); 3951b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x4); 3952b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x5); 3953b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff80, x6); 3954b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000080, x7); 3955b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 3956b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 3957b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x10); 3958b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffe, x11); 3959b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x12); 3960b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x13); 3961b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffe, x14); 3962b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000001, x15); 3963b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 3964b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x18); 3965b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffffffe, x19); 3966b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x20); 3967b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x21); 3968b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff8000000000, x22); 3969b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000008000000000, x23); 3970b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 3971b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x25); 3972b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffffffe, x26); 3973b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x27); 3974b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x28); 3975b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffffffffc00, x29); 3976b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000400, x30); 3977b8021494Sopenharmony_ci } 3978b8021494Sopenharmony_ci} 3979b8021494Sopenharmony_ci 3980b8021494Sopenharmony_ci 3981b8021494Sopenharmony_ciTEST(fcvtmu) { 3982b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 3983b8021494Sopenharmony_ci 3984b8021494Sopenharmony_ci START(); 3985b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 3986b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 3987b8021494Sopenharmony_ci __ Fmov(s2, 1.5); 3988b8021494Sopenharmony_ci __ Fmov(s3, -1.5); 3989b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 3990b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 3991b8021494Sopenharmony_ci __ Fmov(s6, 0x7fffff80); // Largest float < INT32_MAX. 3992b8021494Sopenharmony_ci __ Fneg(s7, s6); // Smallest float > INT32_MIN. 3993b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 3994b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 3995b8021494Sopenharmony_ci __ Fmov(d10, 1.5); 3996b8021494Sopenharmony_ci __ Fmov(d11, -1.5); 3997b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 3998b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 3999b8021494Sopenharmony_ci __ Fmov(d14, kWMaxInt - 1); 4000b8021494Sopenharmony_ci __ Fmov(d15, kWMinInt + 1); 4001b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 4002b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 4003b8021494Sopenharmony_ci __ Fmov(s19, -1.5); 4004b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 4005b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 4006b8021494Sopenharmony_ci __ Fmov(s22, 0x7fffff8000000000); // Largest float < INT64_MAX. 4007b8021494Sopenharmony_ci __ Fneg(s23, s22); // Smallest float > INT64_MIN. 4008b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 4009b8021494Sopenharmony_ci __ Fmov(d25, 1.5); 4010b8021494Sopenharmony_ci __ Fmov(d26, -1.5); 4011b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 4012b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 4013b8021494Sopenharmony_ci __ Fmov(d29, 0x7ffffffffffffc00); // Largest double < INT64_MAX. 4014b8021494Sopenharmony_ci __ Fneg(d30, d29); // Smallest double > INT64_MIN. 4015b8021494Sopenharmony_ci 4016b8021494Sopenharmony_ci __ Fcvtmu(w0, s0); 4017b8021494Sopenharmony_ci __ Fcvtmu(w1, s1); 4018b8021494Sopenharmony_ci __ Fcvtmu(w2, s2); 4019b8021494Sopenharmony_ci __ Fcvtmu(w3, s3); 4020b8021494Sopenharmony_ci __ Fcvtmu(w4, s4); 4021b8021494Sopenharmony_ci __ Fcvtmu(w5, s5); 4022b8021494Sopenharmony_ci __ Fcvtmu(w6, s6); 4023b8021494Sopenharmony_ci __ Fcvtmu(w7, s7); 4024b8021494Sopenharmony_ci __ Fcvtmu(w8, d8); 4025b8021494Sopenharmony_ci __ Fcvtmu(w9, d9); 4026b8021494Sopenharmony_ci __ Fcvtmu(w10, d10); 4027b8021494Sopenharmony_ci __ Fcvtmu(w11, d11); 4028b8021494Sopenharmony_ci __ Fcvtmu(w12, d12); 4029b8021494Sopenharmony_ci __ Fcvtmu(w13, d13); 4030b8021494Sopenharmony_ci __ Fcvtmu(w14, d14); 4031b8021494Sopenharmony_ci __ Fcvtmu(x17, s17); 4032b8021494Sopenharmony_ci __ Fcvtmu(x18, s18); 4033b8021494Sopenharmony_ci __ Fcvtmu(x19, s19); 4034b8021494Sopenharmony_ci __ Fcvtmu(x20, s20); 4035b8021494Sopenharmony_ci __ Fcvtmu(x21, s21); 4036b8021494Sopenharmony_ci __ Fcvtmu(x22, s22); 4037b8021494Sopenharmony_ci __ Fcvtmu(x23, s23); 4038b8021494Sopenharmony_ci __ Fcvtmu(x24, d24); 4039b8021494Sopenharmony_ci __ Fcvtmu(x25, d25); 4040b8021494Sopenharmony_ci __ Fcvtmu(x26, d26); 4041b8021494Sopenharmony_ci __ Fcvtmu(x27, d27); 4042b8021494Sopenharmony_ci __ Fcvtmu(x28, d28); 4043b8021494Sopenharmony_ci __ Fcvtmu(x29, d29); 4044b8021494Sopenharmony_ci __ Fcvtmu(x30, d30); 4045b8021494Sopenharmony_ci END(); 4046b8021494Sopenharmony_ci 4047b8021494Sopenharmony_ci if (CAN_RUN()) { 4048b8021494Sopenharmony_ci RUN(); 4049b8021494Sopenharmony_ci 4050b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 4051b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 4052b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x2); 4053b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x3); 4054b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x4); 4055b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x5); 4056b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff80, x6); 4057b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x7); 4058b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 4059b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 4060b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x10); 4061b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x11); 4062b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x12); 4063b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x13); 4064b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffe, x14); 4065b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 4066b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x18); 4067b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x19); 4068b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x20); 4069b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x21); 4070b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff8000000000, x22); 4071b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x23); 4072b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 4073b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x25); 4074b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x26); 4075b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x27); 4076b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x28); 4077b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffffffffc00, x29); 4078b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x30); 4079b8021494Sopenharmony_ci } 4080b8021494Sopenharmony_ci} 4081b8021494Sopenharmony_ci 4082b8021494Sopenharmony_ci 4083b8021494Sopenharmony_ciTEST(fcvtns) { 4084b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 4085b8021494Sopenharmony_ci 4086b8021494Sopenharmony_ci START(); 4087b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 4088b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 4089b8021494Sopenharmony_ci __ Fmov(s2, 1.5); 4090b8021494Sopenharmony_ci __ Fmov(s3, -1.5); 4091b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 4092b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 4093b8021494Sopenharmony_ci __ Fmov(s6, 0x7fffff80); // Largest float < INT32_MAX. 4094b8021494Sopenharmony_ci __ Fneg(s7, s6); // Smallest float > INT32_MIN. 4095b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 4096b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 4097b8021494Sopenharmony_ci __ Fmov(d10, 1.5); 4098b8021494Sopenharmony_ci __ Fmov(d11, -1.5); 4099b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 4100b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 4101b8021494Sopenharmony_ci __ Fmov(d14, kWMaxInt - 1); 4102b8021494Sopenharmony_ci __ Fmov(d15, kWMinInt + 1); 4103b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 4104b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 4105b8021494Sopenharmony_ci __ Fmov(s19, -1.5); 4106b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 4107b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 4108b8021494Sopenharmony_ci __ Fmov(s22, 0x7fffff8000000000); // Largest float < INT64_MAX. 4109b8021494Sopenharmony_ci __ Fneg(s23, s22); // Smallest float > INT64_MIN. 4110b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 4111b8021494Sopenharmony_ci __ Fmov(d25, 1.5); 4112b8021494Sopenharmony_ci __ Fmov(d26, -1.5); 4113b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 4114b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 4115b8021494Sopenharmony_ci __ Fmov(d29, 0x7ffffffffffffc00); // Largest double < INT64_MAX. 4116b8021494Sopenharmony_ci __ Fneg(d30, d29); // Smallest double > INT64_MIN. 4117b8021494Sopenharmony_ci 4118b8021494Sopenharmony_ci __ Fcvtns(w0, s0); 4119b8021494Sopenharmony_ci __ Fcvtns(w1, s1); 4120b8021494Sopenharmony_ci __ Fcvtns(w2, s2); 4121b8021494Sopenharmony_ci __ Fcvtns(w3, s3); 4122b8021494Sopenharmony_ci __ Fcvtns(w4, s4); 4123b8021494Sopenharmony_ci __ Fcvtns(w5, s5); 4124b8021494Sopenharmony_ci __ Fcvtns(w6, s6); 4125b8021494Sopenharmony_ci __ Fcvtns(w7, s7); 4126b8021494Sopenharmony_ci __ Fcvtns(w8, d8); 4127b8021494Sopenharmony_ci __ Fcvtns(w9, d9); 4128b8021494Sopenharmony_ci __ Fcvtns(w10, d10); 4129b8021494Sopenharmony_ci __ Fcvtns(w11, d11); 4130b8021494Sopenharmony_ci __ Fcvtns(w12, d12); 4131b8021494Sopenharmony_ci __ Fcvtns(w13, d13); 4132b8021494Sopenharmony_ci __ Fcvtns(w14, d14); 4133b8021494Sopenharmony_ci __ Fcvtns(w15, d15); 4134b8021494Sopenharmony_ci __ Fcvtns(x17, s17); 4135b8021494Sopenharmony_ci __ Fcvtns(x18, s18); 4136b8021494Sopenharmony_ci __ Fcvtns(x19, s19); 4137b8021494Sopenharmony_ci __ Fcvtns(x20, s20); 4138b8021494Sopenharmony_ci __ Fcvtns(x21, s21); 4139b8021494Sopenharmony_ci __ Fcvtns(x22, s22); 4140b8021494Sopenharmony_ci __ Fcvtns(x23, s23); 4141b8021494Sopenharmony_ci __ Fcvtns(x24, d24); 4142b8021494Sopenharmony_ci __ Fcvtns(x25, d25); 4143b8021494Sopenharmony_ci __ Fcvtns(x26, d26); 4144b8021494Sopenharmony_ci __ Fcvtns(x27, d27); 4145b8021494Sopenharmony_ci __ Fcvtns(x28, d28); 4146b8021494Sopenharmony_ci __ Fcvtns(x29, d29); 4147b8021494Sopenharmony_ci __ Fcvtns(x30, d30); 4148b8021494Sopenharmony_ci END(); 4149b8021494Sopenharmony_ci 4150b8021494Sopenharmony_ci if (CAN_RUN()) { 4151b8021494Sopenharmony_ci RUN(); 4152b8021494Sopenharmony_ci 4153b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 4154b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 4155b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x2); 4156b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffe, x3); 4157b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x4); 4158b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x5); 4159b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff80, x6); 4160b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000080, x7); 4161b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 4162b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 4163b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x10); 4164b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffe, x11); 4165b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x12); 4166b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x13); 4167b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffe, x14); 4168b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000001, x15); 4169b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 4170b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x18); 4171b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffffffe, x19); 4172b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x20); 4173b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x21); 4174b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff8000000000, x22); 4175b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000008000000000, x23); 4176b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 4177b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x25); 4178b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffffffe, x26); 4179b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x27); 4180b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x28); 4181b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffffffffc00, x29); 4182b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000400, x30); 4183b8021494Sopenharmony_ci } 4184b8021494Sopenharmony_ci} 4185b8021494Sopenharmony_ci 4186b8021494Sopenharmony_ci 4187b8021494Sopenharmony_ciTEST(fcvtnu) { 4188b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 4189b8021494Sopenharmony_ci 4190b8021494Sopenharmony_ci START(); 4191b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 4192b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 4193b8021494Sopenharmony_ci __ Fmov(s2, 1.5); 4194b8021494Sopenharmony_ci __ Fmov(s3, -1.5); 4195b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 4196b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 4197b8021494Sopenharmony_ci __ Fmov(s6, 0xffffff00); // Largest float < UINT32_MAX. 4198b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 4199b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 4200b8021494Sopenharmony_ci __ Fmov(d10, 1.5); 4201b8021494Sopenharmony_ci __ Fmov(d11, -1.5); 4202b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 4203b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 4204b8021494Sopenharmony_ci __ Fmov(d14, 0xfffffffe); 4205b8021494Sopenharmony_ci __ Fmov(s16, 1.0); 4206b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 4207b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 4208b8021494Sopenharmony_ci __ Fmov(s19, -1.5); 4209b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 4210b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 4211b8021494Sopenharmony_ci __ Fmov(s22, 0xffffff0000000000); // Largest float < UINT64_MAX. 4212b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 4213b8021494Sopenharmony_ci __ Fmov(d25, 1.5); 4214b8021494Sopenharmony_ci __ Fmov(d26, -1.5); 4215b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 4216b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 4217b8021494Sopenharmony_ci __ Fmov(d29, 0xfffffffffffff800); // Largest double < UINT64_MAX. 4218b8021494Sopenharmony_ci __ Fmov(s30, 0x100000000); 4219b8021494Sopenharmony_ci 4220b8021494Sopenharmony_ci __ Fcvtnu(w0, s0); 4221b8021494Sopenharmony_ci __ Fcvtnu(w1, s1); 4222b8021494Sopenharmony_ci __ Fcvtnu(w2, s2); 4223b8021494Sopenharmony_ci __ Fcvtnu(w3, s3); 4224b8021494Sopenharmony_ci __ Fcvtnu(w4, s4); 4225b8021494Sopenharmony_ci __ Fcvtnu(w5, s5); 4226b8021494Sopenharmony_ci __ Fcvtnu(w6, s6); 4227b8021494Sopenharmony_ci __ Fcvtnu(w8, d8); 4228b8021494Sopenharmony_ci __ Fcvtnu(w9, d9); 4229b8021494Sopenharmony_ci __ Fcvtnu(w10, d10); 4230b8021494Sopenharmony_ci __ Fcvtnu(w11, d11); 4231b8021494Sopenharmony_ci __ Fcvtnu(w12, d12); 4232b8021494Sopenharmony_ci __ Fcvtnu(w13, d13); 4233b8021494Sopenharmony_ci __ Fcvtnu(w14, d14); 4234b8021494Sopenharmony_ci __ Fcvtnu(w15, d15); 4235b8021494Sopenharmony_ci __ Fcvtnu(x16, s16); 4236b8021494Sopenharmony_ci __ Fcvtnu(x17, s17); 4237b8021494Sopenharmony_ci __ Fcvtnu(x18, s18); 4238b8021494Sopenharmony_ci __ Fcvtnu(x19, s19); 4239b8021494Sopenharmony_ci __ Fcvtnu(x20, s20); 4240b8021494Sopenharmony_ci __ Fcvtnu(x21, s21); 4241b8021494Sopenharmony_ci __ Fcvtnu(x22, s22); 4242b8021494Sopenharmony_ci __ Fcvtnu(x24, d24); 4243b8021494Sopenharmony_ci __ Fcvtnu(x25, d25); 4244b8021494Sopenharmony_ci __ Fcvtnu(x26, d26); 4245b8021494Sopenharmony_ci __ Fcvtnu(x27, d27); 4246b8021494Sopenharmony_ci __ Fcvtnu(x28, d28); 4247b8021494Sopenharmony_ci __ Fcvtnu(x29, d29); 4248b8021494Sopenharmony_ci __ Fcvtnu(w30, s30); 4249b8021494Sopenharmony_ci END(); 4250b8021494Sopenharmony_ci 4251b8021494Sopenharmony_ci if (CAN_RUN()) { 4252b8021494Sopenharmony_ci RUN(); 4253b8021494Sopenharmony_ci 4254b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 4255b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 4256b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x2); 4257b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x3); 4258b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x4); 4259b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x5); 4260b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffff00, x6); 4261b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 4262b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 4263b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x10); 4264b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x11); 4265b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x12); 4266b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x13); 4267b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffe, x14); 4268b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x16); 4269b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 4270b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x18); 4271b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x19); 4272b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x20); 4273b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x21); 4274b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffff0000000000, x22); 4275b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 4276b8021494Sopenharmony_ci ASSERT_EQUAL_64(2, x25); 4277b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x26); 4278b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x27); 4279b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x28); 4280b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xfffffffffffff800, x29); 4281b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x30); 4282b8021494Sopenharmony_ci } 4283b8021494Sopenharmony_ci} 4284b8021494Sopenharmony_ci 4285b8021494Sopenharmony_ci 4286b8021494Sopenharmony_ciTEST(fcvtzs) { 4287b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 4288b8021494Sopenharmony_ci 4289b8021494Sopenharmony_ci START(); 4290b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 4291b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 4292b8021494Sopenharmony_ci __ Fmov(s2, 1.5); 4293b8021494Sopenharmony_ci __ Fmov(s3, -1.5); 4294b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 4295b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 4296b8021494Sopenharmony_ci __ Fmov(s6, 0x7fffff80); // Largest float < INT32_MAX. 4297b8021494Sopenharmony_ci __ Fneg(s7, s6); // Smallest float > INT32_MIN. 4298b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 4299b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 4300b8021494Sopenharmony_ci __ Fmov(d10, 1.5); 4301b8021494Sopenharmony_ci __ Fmov(d11, -1.5); 4302b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 4303b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 4304b8021494Sopenharmony_ci __ Fmov(d14, kWMaxInt - 1); 4305b8021494Sopenharmony_ci __ Fmov(d15, kWMinInt + 1); 4306b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 4307b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 4308b8021494Sopenharmony_ci __ Fmov(s19, -1.5); 4309b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 4310b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 4311b8021494Sopenharmony_ci __ Fmov(s22, 0x7fffff8000000000); // Largest float < INT64_MAX. 4312b8021494Sopenharmony_ci __ Fneg(s23, s22); // Smallest float > INT64_MIN. 4313b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 4314b8021494Sopenharmony_ci __ Fmov(d25, 1.5); 4315b8021494Sopenharmony_ci __ Fmov(d26, -1.5); 4316b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 4317b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 4318b8021494Sopenharmony_ci __ Fmov(d29, 0x7ffffffffffffc00); // Largest double < INT64_MAX. 4319b8021494Sopenharmony_ci __ Fneg(d30, d29); // Smallest double > INT64_MIN. 4320b8021494Sopenharmony_ci 4321b8021494Sopenharmony_ci __ Fcvtzs(w0, s0); 4322b8021494Sopenharmony_ci __ Fcvtzs(w1, s1); 4323b8021494Sopenharmony_ci __ Fcvtzs(w2, s2); 4324b8021494Sopenharmony_ci __ Fcvtzs(w3, s3); 4325b8021494Sopenharmony_ci __ Fcvtzs(w4, s4); 4326b8021494Sopenharmony_ci __ Fcvtzs(w5, s5); 4327b8021494Sopenharmony_ci __ Fcvtzs(w6, s6); 4328b8021494Sopenharmony_ci __ Fcvtzs(w7, s7); 4329b8021494Sopenharmony_ci __ Fcvtzs(w8, d8); 4330b8021494Sopenharmony_ci __ Fcvtzs(w9, d9); 4331b8021494Sopenharmony_ci __ Fcvtzs(w10, d10); 4332b8021494Sopenharmony_ci __ Fcvtzs(w11, d11); 4333b8021494Sopenharmony_ci __ Fcvtzs(w12, d12); 4334b8021494Sopenharmony_ci __ Fcvtzs(w13, d13); 4335b8021494Sopenharmony_ci __ Fcvtzs(w14, d14); 4336b8021494Sopenharmony_ci __ Fcvtzs(w15, d15); 4337b8021494Sopenharmony_ci __ Fcvtzs(x17, s17); 4338b8021494Sopenharmony_ci __ Fcvtzs(x18, s18); 4339b8021494Sopenharmony_ci __ Fcvtzs(x19, s19); 4340b8021494Sopenharmony_ci __ Fcvtzs(x20, s20); 4341b8021494Sopenharmony_ci __ Fcvtzs(x21, s21); 4342b8021494Sopenharmony_ci __ Fcvtzs(x22, s22); 4343b8021494Sopenharmony_ci __ Fcvtzs(x23, s23); 4344b8021494Sopenharmony_ci __ Fcvtzs(x24, d24); 4345b8021494Sopenharmony_ci __ Fcvtzs(x25, d25); 4346b8021494Sopenharmony_ci __ Fcvtzs(x26, d26); 4347b8021494Sopenharmony_ci __ Fcvtzs(x27, d27); 4348b8021494Sopenharmony_ci __ Fcvtzs(x28, d28); 4349b8021494Sopenharmony_ci __ Fcvtzs(x29, d29); 4350b8021494Sopenharmony_ci __ Fcvtzs(x30, d30); 4351b8021494Sopenharmony_ci END(); 4352b8021494Sopenharmony_ci 4353b8021494Sopenharmony_ci if (CAN_RUN()) { 4354b8021494Sopenharmony_ci RUN(); 4355b8021494Sopenharmony_ci 4356b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 4357b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 4358b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x2); 4359b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x3); 4360b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x4); 4361b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x5); 4362b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff80, x6); 4363b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000080, x7); 4364b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 4365b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 4366b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x10); 4367b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x11); 4368b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffff, x12); 4369b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000000, x13); 4370b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffe, x14); 4371b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x80000001, x15); 4372b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 4373b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x18); 4374b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x19); 4375b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x20); 4376b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x21); 4377b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff8000000000, x22); 4378b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000008000000000, x23); 4379b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 4380b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x25); 4381b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x26); 4382b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffffffffffffff, x27); 4383b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000000, x28); 4384b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffffffffc00, x29); 4385b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x8000000000000400, x30); 4386b8021494Sopenharmony_ci } 4387b8021494Sopenharmony_ci} 4388b8021494Sopenharmony_ci 4389b8021494Sopenharmony_civoid FjcvtzsHelper(uint64_t value, uint64_t expected, uint32_t expected_z) { 4390b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kJSCVT); 4391b8021494Sopenharmony_ci START(); 4392b8021494Sopenharmony_ci __ Fmov(d0, RawbitsToDouble(value)); 4393b8021494Sopenharmony_ci __ Fjcvtzs(w0, d0); 4394b8021494Sopenharmony_ci __ Mrs(x1, NZCV); 4395b8021494Sopenharmony_ci END(); 4396b8021494Sopenharmony_ci 4397b8021494Sopenharmony_ci if (CAN_RUN()) { 4398b8021494Sopenharmony_ci RUN(); 4399b8021494Sopenharmony_ci ASSERT_EQUAL_64(expected, x0); 4400b8021494Sopenharmony_ci ASSERT_EQUAL_32(expected_z, w1); 4401b8021494Sopenharmony_ci } 4402b8021494Sopenharmony_ci} 4403b8021494Sopenharmony_ci 4404b8021494Sopenharmony_ciTEST(fjcvtzs) { 4405b8021494Sopenharmony_ci /* Simple values. */ 4406b8021494Sopenharmony_ci FjcvtzsHelper(0x0000000000000000, 0, ZFlag); // 0.0 4407b8021494Sopenharmony_ci FjcvtzsHelper(0x0010000000000000, 0, NoFlag); // The smallest normal value. 4408b8021494Sopenharmony_ci FjcvtzsHelper(0x3fdfffffffffffff, 0, NoFlag); // The value just below 0.5. 4409b8021494Sopenharmony_ci FjcvtzsHelper(0x3fe0000000000000, 0, NoFlag); // 0.5 4410b8021494Sopenharmony_ci FjcvtzsHelper(0x3fe0000000000001, 0, NoFlag); // The value just above 0.5. 4411b8021494Sopenharmony_ci FjcvtzsHelper(0x3fefffffffffffff, 0, NoFlag); // The value just below 1.0. 4412b8021494Sopenharmony_ci FjcvtzsHelper(0x3ff0000000000000, 1, ZFlag); // 1.0 4413b8021494Sopenharmony_ci FjcvtzsHelper(0x3ff0000000000001, 1, NoFlag); // The value just above 1.0. 4414b8021494Sopenharmony_ci FjcvtzsHelper(0x3ff8000000000000, 1, NoFlag); // 1.5 4415b8021494Sopenharmony_ci FjcvtzsHelper(0x4024000000000000, 10, ZFlag); // 10 4416b8021494Sopenharmony_ci FjcvtzsHelper(0x7fefffffffffffff, 0, NoFlag); // The largest finite value. 4417b8021494Sopenharmony_ci 4418b8021494Sopenharmony_ci /* Infinity. */ 4419b8021494Sopenharmony_ci FjcvtzsHelper(0x7ff0000000000000, 0, NoFlag); 4420b8021494Sopenharmony_ci 4421b8021494Sopenharmony_ci /* NaNs. */ 4422b8021494Sopenharmony_ci /* - Quiet NaNs */ 4423b8021494Sopenharmony_ci FjcvtzsHelper(0x7ff923456789abcd, 0, NoFlag); 4424b8021494Sopenharmony_ci FjcvtzsHelper(0x7ff8000000000000, 0, NoFlag); 4425b8021494Sopenharmony_ci /* - Signalling NaNs */ 4426b8021494Sopenharmony_ci FjcvtzsHelper(0x7ff123456789abcd, 0, NoFlag); 4427b8021494Sopenharmony_ci FjcvtzsHelper(0x7ff0000000000001, 0, NoFlag); 4428b8021494Sopenharmony_ci 4429b8021494Sopenharmony_ci /* Subnormals. */ 4430b8021494Sopenharmony_ci /* - A recognisable bit pattern. */ 4431b8021494Sopenharmony_ci FjcvtzsHelper(0x000123456789abcd, 0, NoFlag); 4432b8021494Sopenharmony_ci /* - The largest subnormal value. */ 4433b8021494Sopenharmony_ci FjcvtzsHelper(0x000fffffffffffff, 0, NoFlag); 4434b8021494Sopenharmony_ci /* - The smallest subnormal value. */ 4435b8021494Sopenharmony_ci FjcvtzsHelper(0x0000000000000001, 0, NoFlag); 4436b8021494Sopenharmony_ci 4437b8021494Sopenharmony_ci /* The same values again, but negated. */ 4438b8021494Sopenharmony_ci FjcvtzsHelper(0x8000000000000000, 0, NoFlag); 4439b8021494Sopenharmony_ci FjcvtzsHelper(0x8010000000000000, 0, NoFlag); 4440b8021494Sopenharmony_ci FjcvtzsHelper(0xbfdfffffffffffff, 0, NoFlag); 4441b8021494Sopenharmony_ci FjcvtzsHelper(0xbfe0000000000000, 0, NoFlag); 4442b8021494Sopenharmony_ci FjcvtzsHelper(0xbfe0000000000001, 0, NoFlag); 4443b8021494Sopenharmony_ci FjcvtzsHelper(0xbfefffffffffffff, 0, NoFlag); 4444b8021494Sopenharmony_ci FjcvtzsHelper(0xbff0000000000000, 0xffffffff, ZFlag); 4445b8021494Sopenharmony_ci FjcvtzsHelper(0xbff0000000000001, 0xffffffff, NoFlag); 4446b8021494Sopenharmony_ci FjcvtzsHelper(0xbff8000000000000, 0xffffffff, NoFlag); 4447b8021494Sopenharmony_ci FjcvtzsHelper(0xc024000000000000, 0xfffffff6, ZFlag); 4448b8021494Sopenharmony_ci FjcvtzsHelper(0xffefffffffffffff, 0, NoFlag); 4449b8021494Sopenharmony_ci FjcvtzsHelper(0xfff0000000000000, 0, NoFlag); 4450b8021494Sopenharmony_ci FjcvtzsHelper(0xfff923456789abcd, 0, NoFlag); 4451b8021494Sopenharmony_ci FjcvtzsHelper(0xfff8000000000000, 0, NoFlag); 4452b8021494Sopenharmony_ci FjcvtzsHelper(0xfff123456789abcd, 0, NoFlag); 4453b8021494Sopenharmony_ci FjcvtzsHelper(0xfff0000000000001, 0, NoFlag); 4454b8021494Sopenharmony_ci FjcvtzsHelper(0x800123456789abcd, 0, NoFlag); 4455b8021494Sopenharmony_ci FjcvtzsHelper(0x800fffffffffffff, 0, NoFlag); 4456b8021494Sopenharmony_ci FjcvtzsHelper(0x8000000000000001, 0, NoFlag); 4457b8021494Sopenharmony_ci 4458b8021494Sopenharmony_ci // Test floating-point numbers of every possible exponent, most of the 4459b8021494Sopenharmony_ci // expected values are zero but there is a range of exponents where the 4460b8021494Sopenharmony_ci // results are shifted parts of this mantissa. 4461b8021494Sopenharmony_ci uint64_t mantissa = 0x0001234567890abc; 4462b8021494Sopenharmony_ci 4463b8021494Sopenharmony_ci // Between an exponent of 0 and 52, only some of the top bits of the 4464b8021494Sopenharmony_ci // mantissa are above the decimal position of doubles so the mantissa is 4465b8021494Sopenharmony_ci // shifted to the right down to just those top bits. Above 52, all bits 4466b8021494Sopenharmony_ci // of the mantissa are shifted left above the decimal position until it 4467b8021494Sopenharmony_ci // reaches 52 + 64 where all the bits are shifted out of the range of 64-bit 4468b8021494Sopenharmony_ci // integers. 4469b8021494Sopenharmony_ci int first_exp_boundary = 52; 4470b8021494Sopenharmony_ci int second_exp_boundary = first_exp_boundary + 64; 4471b8021494Sopenharmony_ci for (int exponent = 0; exponent < 2048; exponent += 8) { 4472b8021494Sopenharmony_ci int e = exponent - 1023; 4473b8021494Sopenharmony_ci 4474b8021494Sopenharmony_ci uint64_t expected = 0; 4475b8021494Sopenharmony_ci if (e < 0) { 4476b8021494Sopenharmony_ci expected = 0; 4477b8021494Sopenharmony_ci } else if (e <= first_exp_boundary) { 4478b8021494Sopenharmony_ci expected = (UINT64_C(1) << e) | (mantissa >> (52 - e)); 4479b8021494Sopenharmony_ci expected &= 0xffffffff; 4480b8021494Sopenharmony_ci } else if (e < second_exp_boundary) { 4481b8021494Sopenharmony_ci expected = (mantissa << (e - 52)) & 0xffffffff; 4482b8021494Sopenharmony_ci } else { 4483b8021494Sopenharmony_ci expected = 0; 4484b8021494Sopenharmony_ci } 4485b8021494Sopenharmony_ci 4486b8021494Sopenharmony_ci uint64_t value = (static_cast<uint64_t>(exponent) << 52) | mantissa; 4487b8021494Sopenharmony_ci FjcvtzsHelper(value, expected, NoFlag); 4488b8021494Sopenharmony_ci FjcvtzsHelper(value | kDSignMask, (-expected) & 0xffffffff, NoFlag); 4489b8021494Sopenharmony_ci } 4490b8021494Sopenharmony_ci} 4491b8021494Sopenharmony_ci 4492b8021494Sopenharmony_ciTEST(fcvtzu) { 4493b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 4494b8021494Sopenharmony_ci 4495b8021494Sopenharmony_ci START(); 4496b8021494Sopenharmony_ci __ Fmov(s0, 1.0); 4497b8021494Sopenharmony_ci __ Fmov(s1, 1.1); 4498b8021494Sopenharmony_ci __ Fmov(s2, 1.5); 4499b8021494Sopenharmony_ci __ Fmov(s3, -1.5); 4500b8021494Sopenharmony_ci __ Fmov(s4, kFP32PositiveInfinity); 4501b8021494Sopenharmony_ci __ Fmov(s5, kFP32NegativeInfinity); 4502b8021494Sopenharmony_ci __ Fmov(s6, 0x7fffff80); // Largest float < INT32_MAX. 4503b8021494Sopenharmony_ci __ Fneg(s7, s6); // Smallest float > INT32_MIN. 4504b8021494Sopenharmony_ci __ Fmov(d8, 1.0); 4505b8021494Sopenharmony_ci __ Fmov(d9, 1.1); 4506b8021494Sopenharmony_ci __ Fmov(d10, 1.5); 4507b8021494Sopenharmony_ci __ Fmov(d11, -1.5); 4508b8021494Sopenharmony_ci __ Fmov(d12, kFP64PositiveInfinity); 4509b8021494Sopenharmony_ci __ Fmov(d13, kFP64NegativeInfinity); 4510b8021494Sopenharmony_ci __ Fmov(d14, kWMaxInt - 1); 4511b8021494Sopenharmony_ci __ Fmov(d15, kWMinInt + 1); 4512b8021494Sopenharmony_ci __ Fmov(s17, 1.1); 4513b8021494Sopenharmony_ci __ Fmov(s18, 1.5); 4514b8021494Sopenharmony_ci __ Fmov(s19, -1.5); 4515b8021494Sopenharmony_ci __ Fmov(s20, kFP32PositiveInfinity); 4516b8021494Sopenharmony_ci __ Fmov(s21, kFP32NegativeInfinity); 4517b8021494Sopenharmony_ci __ Fmov(s22, 0x7fffff8000000000); // Largest float < INT64_MAX. 4518b8021494Sopenharmony_ci __ Fneg(s23, s22); // Smallest float > INT64_MIN. 4519b8021494Sopenharmony_ci __ Fmov(d24, 1.1); 4520b8021494Sopenharmony_ci __ Fmov(d25, 1.5); 4521b8021494Sopenharmony_ci __ Fmov(d26, -1.5); 4522b8021494Sopenharmony_ci __ Fmov(d27, kFP64PositiveInfinity); 4523b8021494Sopenharmony_ci __ Fmov(d28, kFP64NegativeInfinity); 4524b8021494Sopenharmony_ci __ Fmov(d29, 0x7ffffffffffffc00); // Largest double < INT64_MAX. 4525b8021494Sopenharmony_ci __ Fneg(d30, d29); // Smallest double > INT64_MIN. 4526b8021494Sopenharmony_ci 4527b8021494Sopenharmony_ci __ Fcvtzu(w0, s0); 4528b8021494Sopenharmony_ci __ Fcvtzu(w1, s1); 4529b8021494Sopenharmony_ci __ Fcvtzu(w2, s2); 4530b8021494Sopenharmony_ci __ Fcvtzu(w3, s3); 4531b8021494Sopenharmony_ci __ Fcvtzu(w4, s4); 4532b8021494Sopenharmony_ci __ Fcvtzu(w5, s5); 4533b8021494Sopenharmony_ci __ Fcvtzu(w6, s6); 4534b8021494Sopenharmony_ci __ Fcvtzu(w7, s7); 4535b8021494Sopenharmony_ci __ Fcvtzu(w8, d8); 4536b8021494Sopenharmony_ci __ Fcvtzu(w9, d9); 4537b8021494Sopenharmony_ci __ Fcvtzu(w10, d10); 4538b8021494Sopenharmony_ci __ Fcvtzu(w11, d11); 4539b8021494Sopenharmony_ci __ Fcvtzu(w12, d12); 4540b8021494Sopenharmony_ci __ Fcvtzu(w13, d13); 4541b8021494Sopenharmony_ci __ Fcvtzu(w14, d14); 4542b8021494Sopenharmony_ci __ Fcvtzu(x17, s17); 4543b8021494Sopenharmony_ci __ Fcvtzu(x18, s18); 4544b8021494Sopenharmony_ci __ Fcvtzu(x19, s19); 4545b8021494Sopenharmony_ci __ Fcvtzu(x20, s20); 4546b8021494Sopenharmony_ci __ Fcvtzu(x21, s21); 4547b8021494Sopenharmony_ci __ Fcvtzu(x22, s22); 4548b8021494Sopenharmony_ci __ Fcvtzu(x23, s23); 4549b8021494Sopenharmony_ci __ Fcvtzu(x24, d24); 4550b8021494Sopenharmony_ci __ Fcvtzu(x25, d25); 4551b8021494Sopenharmony_ci __ Fcvtzu(x26, d26); 4552b8021494Sopenharmony_ci __ Fcvtzu(x27, d27); 4553b8021494Sopenharmony_ci __ Fcvtzu(x28, d28); 4554b8021494Sopenharmony_ci __ Fcvtzu(x29, d29); 4555b8021494Sopenharmony_ci __ Fcvtzu(x30, d30); 4556b8021494Sopenharmony_ci END(); 4557b8021494Sopenharmony_ci 4558b8021494Sopenharmony_ci if (CAN_RUN()) { 4559b8021494Sopenharmony_ci RUN(); 4560b8021494Sopenharmony_ci 4561b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x0); 4562b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x1); 4563b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x2); 4564b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x3); 4565b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x4); 4566b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x5); 4567b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff80, x6); 4568b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x7); 4569b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x8); 4570b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x9); 4571b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x10); 4572b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x11); 4573b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffff, x12); 4574b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x13); 4575b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffe, x14); 4576b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x17); 4577b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x18); 4578b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x19); 4579b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x20); 4580b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x21); 4581b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7fffff8000000000, x22); 4582b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x23); 4583b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x24); 4584b8021494Sopenharmony_ci ASSERT_EQUAL_64(1, x25); 4585b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x26); 4586b8021494Sopenharmony_ci ASSERT_EQUAL_64(0xffffffffffffffff, x27); 4587b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x28); 4588b8021494Sopenharmony_ci ASSERT_EQUAL_64(0x7ffffffffffffc00, x29); 4589b8021494Sopenharmony_ci ASSERT_EQUAL_64(0, x30); 4590b8021494Sopenharmony_ci } 4591b8021494Sopenharmony_ci} 4592b8021494Sopenharmony_ci 4593b8021494Sopenharmony_ci// Test that scvtf and ucvtf can convert the 64-bit input into the expected 4594b8021494Sopenharmony_ci// value. All possible values of 'fbits' are tested. The expected value is 4595b8021494Sopenharmony_ci// modified accordingly in each case. 4596b8021494Sopenharmony_ci// 4597b8021494Sopenharmony_ci// The expected value is specified as the bit encoding of the expected double 4598b8021494Sopenharmony_ci// produced by scvtf (expected_scvtf_bits) as well as ucvtf 4599b8021494Sopenharmony_ci// (expected_ucvtf_bits). 4600b8021494Sopenharmony_ci// 4601b8021494Sopenharmony_ci// Where the input value is representable by int32_t or uint32_t, conversions 4602b8021494Sopenharmony_ci// from W registers will also be tested. 4603b8021494Sopenharmony_cistatic void TestUScvtfHelper(uint64_t in, 4604b8021494Sopenharmony_ci uint64_t expected_scvtf_bits, 4605b8021494Sopenharmony_ci uint64_t expected_ucvtf_bits) { 4606b8021494Sopenharmony_ci uint64_t u64 = in; 4607b8021494Sopenharmony_ci uint32_t u32 = u64 & 0xffffffff; 4608b8021494Sopenharmony_ci int64_t s64 = static_cast<int64_t>(in); 4609b8021494Sopenharmony_ci int32_t s32 = s64 & 0x7fffffff; 4610b8021494Sopenharmony_ci 4611b8021494Sopenharmony_ci bool cvtf_s32 = (s64 == s32); 4612b8021494Sopenharmony_ci bool cvtf_u32 = (u64 == u32); 4613b8021494Sopenharmony_ci 4614b8021494Sopenharmony_ci double results_scvtf_x[65]; 4615b8021494Sopenharmony_ci double results_ucvtf_x[65]; 4616b8021494Sopenharmony_ci double results_scvtf_w[33]; 4617b8021494Sopenharmony_ci double results_ucvtf_w[33]; 4618b8021494Sopenharmony_ci 4619b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 4620b8021494Sopenharmony_ci 4621b8021494Sopenharmony_ci START(); 4622b8021494Sopenharmony_ci 4623b8021494Sopenharmony_ci __ Mov(x0, reinterpret_cast<uintptr_t>(results_scvtf_x)); 4624b8021494Sopenharmony_ci __ Mov(x1, reinterpret_cast<uintptr_t>(results_ucvtf_x)); 4625b8021494Sopenharmony_ci __ Mov(x2, reinterpret_cast<uintptr_t>(results_scvtf_w)); 4626b8021494Sopenharmony_ci __ Mov(x3, reinterpret_cast<uintptr_t>(results_ucvtf_w)); 4627b8021494Sopenharmony_ci 4628b8021494Sopenharmony_ci __ Mov(x10, s64); 4629b8021494Sopenharmony_ci 4630b8021494Sopenharmony_ci // Corrupt the top word, in case it is accidentally used during W-register 4631b8021494Sopenharmony_ci // conversions. 4632b8021494Sopenharmony_ci __ Mov(x11, 0x5555555555555555); 4633b8021494Sopenharmony_ci __ Bfi(x11, x10, 0, kWRegSize); 4634b8021494Sopenharmony_ci 4635b8021494Sopenharmony_ci // Test integer conversions. 4636b8021494Sopenharmony_ci __ Scvtf(d0, x10); 4637b8021494Sopenharmony_ci __ Ucvtf(d1, x10); 4638b8021494Sopenharmony_ci __ Scvtf(d2, w11); 4639b8021494Sopenharmony_ci __ Ucvtf(d3, w11); 4640b8021494Sopenharmony_ci __ Str(d0, MemOperand(x0)); 4641b8021494Sopenharmony_ci __ Str(d1, MemOperand(x1)); 4642b8021494Sopenharmony_ci __ Str(d2, MemOperand(x2)); 4643b8021494Sopenharmony_ci __ Str(d3, MemOperand(x3)); 4644b8021494Sopenharmony_ci 4645b8021494Sopenharmony_ci // Test all possible values of fbits. 4646b8021494Sopenharmony_ci for (int fbits = 1; fbits <= 32; fbits++) { 4647b8021494Sopenharmony_ci __ Scvtf(d0, x10, fbits); 4648b8021494Sopenharmony_ci __ Ucvtf(d1, x10, fbits); 4649b8021494Sopenharmony_ci __ Scvtf(d2, w11, fbits); 4650b8021494Sopenharmony_ci __ Ucvtf(d3, w11, fbits); 4651b8021494Sopenharmony_ci __ Str(d0, MemOperand(x0, fbits * kDRegSizeInBytes)); 4652b8021494Sopenharmony_ci __ Str(d1, MemOperand(x1, fbits * kDRegSizeInBytes)); 4653b8021494Sopenharmony_ci __ Str(d2, MemOperand(x2, fbits * kDRegSizeInBytes)); 4654b8021494Sopenharmony_ci __ Str(d3, MemOperand(x3, fbits * kDRegSizeInBytes)); 4655b8021494Sopenharmony_ci } 4656b8021494Sopenharmony_ci 4657b8021494Sopenharmony_ci // Conversions from W registers can only handle fbits values <= 32, so just 4658b8021494Sopenharmony_ci // test conversions from X registers for 32 < fbits <= 64. 4659b8021494Sopenharmony_ci for (int fbits = 33; fbits <= 64; fbits++) { 4660b8021494Sopenharmony_ci __ Scvtf(d0, x10, fbits); 4661b8021494Sopenharmony_ci __ Ucvtf(d1, x10, fbits); 4662b8021494Sopenharmony_ci __ Str(d0, MemOperand(x0, fbits * kDRegSizeInBytes)); 4663b8021494Sopenharmony_ci __ Str(d1, MemOperand(x1, fbits * kDRegSizeInBytes)); 4664b8021494Sopenharmony_ci } 4665b8021494Sopenharmony_ci 4666b8021494Sopenharmony_ci END(); 4667b8021494Sopenharmony_ci if (CAN_RUN()) { 4668b8021494Sopenharmony_ci RUN(); 4669b8021494Sopenharmony_ci 4670b8021494Sopenharmony_ci // Check the results. 4671b8021494Sopenharmony_ci double expected_scvtf_base = RawbitsToDouble(expected_scvtf_bits); 4672b8021494Sopenharmony_ci double expected_ucvtf_base = RawbitsToDouble(expected_ucvtf_bits); 4673b8021494Sopenharmony_ci 4674b8021494Sopenharmony_ci for (int fbits = 0; fbits <= 32; fbits++) { 4675b8021494Sopenharmony_ci double expected_scvtf = expected_scvtf_base / std::pow(2, fbits); 4676b8021494Sopenharmony_ci double expected_ucvtf = expected_ucvtf_base / std::pow(2, fbits); 4677b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_x[fbits]); 4678b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_x[fbits]); 4679b8021494Sopenharmony_ci if (cvtf_s32) ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_w[fbits]); 4680b8021494Sopenharmony_ci if (cvtf_u32) ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_w[fbits]); 4681b8021494Sopenharmony_ci } 4682b8021494Sopenharmony_ci for (int fbits = 33; fbits <= 64; fbits++) { 4683b8021494Sopenharmony_ci double expected_scvtf = expected_scvtf_base / std::pow(2, fbits); 4684b8021494Sopenharmony_ci double expected_ucvtf = expected_ucvtf_base / std::pow(2, fbits); 4685b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_x[fbits]); 4686b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_x[fbits]); 4687b8021494Sopenharmony_ci } 4688b8021494Sopenharmony_ci } 4689b8021494Sopenharmony_ci} 4690b8021494Sopenharmony_ci 4691b8021494Sopenharmony_ci 4692b8021494Sopenharmony_ciTEST(scvtf_ucvtf_double) { 4693b8021494Sopenharmony_ci // Simple conversions of positive numbers which require no rounding; the 4694b8021494Sopenharmony_ci // results should not depend on the rounding mode, and ucvtf and scvtf should 4695b8021494Sopenharmony_ci // produce the same result. 4696b8021494Sopenharmony_ci TestUScvtfHelper(0x0000000000000000, 0x0000000000000000, 0x0000000000000000); 4697b8021494Sopenharmony_ci TestUScvtfHelper(0x0000000000000001, 0x3ff0000000000000, 0x3ff0000000000000); 4698b8021494Sopenharmony_ci TestUScvtfHelper(0x0000000040000000, 0x41d0000000000000, 0x41d0000000000000); 4699b8021494Sopenharmony_ci TestUScvtfHelper(0x0000000100000000, 0x41f0000000000000, 0x41f0000000000000); 4700b8021494Sopenharmony_ci TestUScvtfHelper(0x4000000000000000, 0x43d0000000000000, 0x43d0000000000000); 4701b8021494Sopenharmony_ci // Test mantissa extremities. 4702b8021494Sopenharmony_ci TestUScvtfHelper(0x4000000000000400, 0x43d0000000000001, 0x43d0000000000001); 4703b8021494Sopenharmony_ci // The largest int32_t that fits in a double. 4704b8021494Sopenharmony_ci TestUScvtfHelper(0x000000007fffffff, 0x41dfffffffc00000, 0x41dfffffffc00000); 4705b8021494Sopenharmony_ci // Values that would be negative if treated as an int32_t. 4706b8021494Sopenharmony_ci TestUScvtfHelper(0x00000000ffffffff, 0x41efffffffe00000, 0x41efffffffe00000); 4707b8021494Sopenharmony_ci TestUScvtfHelper(0x0000000080000000, 0x41e0000000000000, 0x41e0000000000000); 4708b8021494Sopenharmony_ci TestUScvtfHelper(0x0000000080000001, 0x41e0000000200000, 0x41e0000000200000); 4709b8021494Sopenharmony_ci // The largest int64_t that fits in a double. 4710b8021494Sopenharmony_ci TestUScvtfHelper(0x7ffffffffffffc00, 0x43dfffffffffffff, 0x43dfffffffffffff); 4711b8021494Sopenharmony_ci // Check for bit pattern reproduction. 4712b8021494Sopenharmony_ci TestUScvtfHelper(0x0123456789abcde0, 0x43723456789abcde, 0x43723456789abcde); 4713b8021494Sopenharmony_ci TestUScvtfHelper(0x0000000012345678, 0x41b2345678000000, 0x41b2345678000000); 4714b8021494Sopenharmony_ci 4715b8021494Sopenharmony_ci // Simple conversions of negative int64_t values. These require no rounding, 4716b8021494Sopenharmony_ci // and the results should not depend on the rounding mode. 4717b8021494Sopenharmony_ci TestUScvtfHelper(0xffffffffc0000000, 0xc1d0000000000000, 0x43effffffff80000); 4718b8021494Sopenharmony_ci TestUScvtfHelper(0xffffffff00000000, 0xc1f0000000000000, 0x43efffffffe00000); 4719b8021494Sopenharmony_ci TestUScvtfHelper(0xc000000000000000, 0xc3d0000000000000, 0x43e8000000000000); 4720b8021494Sopenharmony_ci 4721b8021494Sopenharmony_ci // Conversions which require rounding. 4722b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000000, 0x43b0000000000000, 0x43b0000000000000); 4723b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000001, 0x43b0000000000000, 0x43b0000000000000); 4724b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000080, 0x43b0000000000000, 0x43b0000000000000); 4725b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000081, 0x43b0000000000001, 0x43b0000000000001); 4726b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000100, 0x43b0000000000001, 0x43b0000000000001); 4727b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000101, 0x43b0000000000001, 0x43b0000000000001); 4728b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000180, 0x43b0000000000002, 0x43b0000000000002); 4729b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000181, 0x43b0000000000002, 0x43b0000000000002); 4730b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000200, 0x43b0000000000002, 0x43b0000000000002); 4731b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000201, 0x43b0000000000002, 0x43b0000000000002); 4732b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000280, 0x43b0000000000002, 0x43b0000000000002); 4733b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000281, 0x43b0000000000003, 0x43b0000000000003); 4734b8021494Sopenharmony_ci TestUScvtfHelper(0x1000000000000300, 0x43b0000000000003, 0x43b0000000000003); 4735b8021494Sopenharmony_ci // Check rounding of negative int64_t values (and large uint64_t values). 4736b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000000, 0xc3e0000000000000, 0x43e0000000000000); 4737b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000001, 0xc3e0000000000000, 0x43e0000000000000); 4738b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000200, 0xc3e0000000000000, 0x43e0000000000000); 4739b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000201, 0xc3dfffffffffffff, 0x43e0000000000000); 4740b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000400, 0xc3dfffffffffffff, 0x43e0000000000000); 4741b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000401, 0xc3dfffffffffffff, 0x43e0000000000001); 4742b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000600, 0xc3dffffffffffffe, 0x43e0000000000001); 4743b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000601, 0xc3dffffffffffffe, 0x43e0000000000001); 4744b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000800, 0xc3dffffffffffffe, 0x43e0000000000001); 4745b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000801, 0xc3dffffffffffffe, 0x43e0000000000001); 4746b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000a00, 0xc3dffffffffffffe, 0x43e0000000000001); 4747b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000a01, 0xc3dffffffffffffd, 0x43e0000000000001); 4748b8021494Sopenharmony_ci TestUScvtfHelper(0x8000000000000c00, 0xc3dffffffffffffd, 0x43e0000000000002); 4749b8021494Sopenharmony_ci // Round up to produce a result that's too big for the input to represent. 4750b8021494Sopenharmony_ci TestUScvtfHelper(0x7ffffffffffffe00, 0x43e0000000000000, 0x43e0000000000000); 4751b8021494Sopenharmony_ci TestUScvtfHelper(0x7fffffffffffffff, 0x43e0000000000000, 0x43e0000000000000); 4752b8021494Sopenharmony_ci TestUScvtfHelper(0xfffffffffffffc00, 0xc090000000000000, 0x43f0000000000000); 4753b8021494Sopenharmony_ci TestUScvtfHelper(0xffffffffffffffff, 0xbff0000000000000, 0x43f0000000000000); 4754b8021494Sopenharmony_ci} 4755b8021494Sopenharmony_ci 4756b8021494Sopenharmony_ci 4757b8021494Sopenharmony_ci// The same as TestUScvtfHelper, but convert to floats. 4758b8021494Sopenharmony_cistatic void TestUScvtf32Helper(uint64_t in, 4759b8021494Sopenharmony_ci uint32_t expected_scvtf_bits, 4760b8021494Sopenharmony_ci uint32_t expected_ucvtf_bits) { 4761b8021494Sopenharmony_ci uint64_t u64 = in; 4762b8021494Sopenharmony_ci uint32_t u32 = u64 & 0xffffffff; 4763b8021494Sopenharmony_ci int64_t s64 = static_cast<int64_t>(in); 4764b8021494Sopenharmony_ci int32_t s32 = s64 & 0x7fffffff; 4765b8021494Sopenharmony_ci 4766b8021494Sopenharmony_ci bool cvtf_s32 = (s64 == s32); 4767b8021494Sopenharmony_ci bool cvtf_u32 = (u64 == u32); 4768b8021494Sopenharmony_ci 4769b8021494Sopenharmony_ci float results_scvtf_x[65]; 4770b8021494Sopenharmony_ci float results_ucvtf_x[65]; 4771b8021494Sopenharmony_ci float results_scvtf_w[33]; 4772b8021494Sopenharmony_ci float results_ucvtf_w[33]; 4773b8021494Sopenharmony_ci 4774b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 4775b8021494Sopenharmony_ci 4776b8021494Sopenharmony_ci START(); 4777b8021494Sopenharmony_ci 4778b8021494Sopenharmony_ci __ Mov(x0, reinterpret_cast<uintptr_t>(results_scvtf_x)); 4779b8021494Sopenharmony_ci __ Mov(x1, reinterpret_cast<uintptr_t>(results_ucvtf_x)); 4780b8021494Sopenharmony_ci __ Mov(x2, reinterpret_cast<uintptr_t>(results_scvtf_w)); 4781b8021494Sopenharmony_ci __ Mov(x3, reinterpret_cast<uintptr_t>(results_ucvtf_w)); 4782b8021494Sopenharmony_ci 4783b8021494Sopenharmony_ci __ Mov(x10, s64); 4784b8021494Sopenharmony_ci 4785b8021494Sopenharmony_ci // Corrupt the top word, in case it is accidentally used during W-register 4786b8021494Sopenharmony_ci // conversions. 4787b8021494Sopenharmony_ci __ Mov(x11, 0x5555555555555555); 4788b8021494Sopenharmony_ci __ Bfi(x11, x10, 0, kWRegSize); 4789b8021494Sopenharmony_ci 4790b8021494Sopenharmony_ci // Test integer conversions. 4791b8021494Sopenharmony_ci __ Scvtf(s0, x10); 4792b8021494Sopenharmony_ci __ Ucvtf(s1, x10); 4793b8021494Sopenharmony_ci __ Scvtf(s2, w11); 4794b8021494Sopenharmony_ci __ Ucvtf(s3, w11); 4795b8021494Sopenharmony_ci __ Str(s0, MemOperand(x0)); 4796b8021494Sopenharmony_ci __ Str(s1, MemOperand(x1)); 4797b8021494Sopenharmony_ci __ Str(s2, MemOperand(x2)); 4798b8021494Sopenharmony_ci __ Str(s3, MemOperand(x3)); 4799b8021494Sopenharmony_ci 4800b8021494Sopenharmony_ci // Test all possible values of fbits. 4801b8021494Sopenharmony_ci for (int fbits = 1; fbits <= 32; fbits++) { 4802b8021494Sopenharmony_ci __ Scvtf(s0, x10, fbits); 4803b8021494Sopenharmony_ci __ Ucvtf(s1, x10, fbits); 4804b8021494Sopenharmony_ci __ Scvtf(s2, w11, fbits); 4805b8021494Sopenharmony_ci __ Ucvtf(s3, w11, fbits); 4806b8021494Sopenharmony_ci __ Str(s0, MemOperand(x0, fbits * kSRegSizeInBytes)); 4807b8021494Sopenharmony_ci __ Str(s1, MemOperand(x1, fbits * kSRegSizeInBytes)); 4808b8021494Sopenharmony_ci __ Str(s2, MemOperand(x2, fbits * kSRegSizeInBytes)); 4809b8021494Sopenharmony_ci __ Str(s3, MemOperand(x3, fbits * kSRegSizeInBytes)); 4810b8021494Sopenharmony_ci } 4811b8021494Sopenharmony_ci 4812b8021494Sopenharmony_ci // Conversions from W registers can only handle fbits values <= 32, so just 4813b8021494Sopenharmony_ci // test conversions from X registers for 32 < fbits <= 64. 4814b8021494Sopenharmony_ci for (int fbits = 33; fbits <= 64; fbits++) { 4815b8021494Sopenharmony_ci __ Scvtf(s0, x10, fbits); 4816b8021494Sopenharmony_ci __ Ucvtf(s1, x10, fbits); 4817b8021494Sopenharmony_ci __ Str(s0, MemOperand(x0, fbits * kSRegSizeInBytes)); 4818b8021494Sopenharmony_ci __ Str(s1, MemOperand(x1, fbits * kSRegSizeInBytes)); 4819b8021494Sopenharmony_ci } 4820b8021494Sopenharmony_ci 4821b8021494Sopenharmony_ci END(); 4822b8021494Sopenharmony_ci if (CAN_RUN()) { 4823b8021494Sopenharmony_ci RUN(); 4824b8021494Sopenharmony_ci 4825b8021494Sopenharmony_ci // Check the results. 4826b8021494Sopenharmony_ci float expected_scvtf_base = RawbitsToFloat(expected_scvtf_bits); 4827b8021494Sopenharmony_ci float expected_ucvtf_base = RawbitsToFloat(expected_ucvtf_bits); 4828b8021494Sopenharmony_ci 4829b8021494Sopenharmony_ci for (int fbits = 0; fbits <= 32; fbits++) { 4830b8021494Sopenharmony_ci float expected_scvtf = expected_scvtf_base / std::pow(2.0f, fbits); 4831b8021494Sopenharmony_ci float expected_ucvtf = expected_ucvtf_base / std::pow(2.0f, fbits); 4832b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected_scvtf, results_scvtf_x[fbits]); 4833b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected_ucvtf, results_ucvtf_x[fbits]); 4834b8021494Sopenharmony_ci if (cvtf_s32) ASSERT_EQUAL_FP32(expected_scvtf, results_scvtf_w[fbits]); 4835b8021494Sopenharmony_ci if (cvtf_u32) ASSERT_EQUAL_FP32(expected_ucvtf, results_ucvtf_w[fbits]); 4836b8021494Sopenharmony_ci } 4837b8021494Sopenharmony_ci for (int fbits = 33; fbits <= 64; fbits++) { 4838b8021494Sopenharmony_ci float expected_scvtf = expected_scvtf_base / std::pow(2.0f, fbits); 4839b8021494Sopenharmony_ci float expected_ucvtf = expected_ucvtf_base / std::pow(2.0f, fbits); 4840b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected_scvtf, results_scvtf_x[fbits]); 4841b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected_ucvtf, results_ucvtf_x[fbits]); 4842b8021494Sopenharmony_ci } 4843b8021494Sopenharmony_ci } 4844b8021494Sopenharmony_ci} 4845b8021494Sopenharmony_ci 4846b8021494Sopenharmony_ci 4847b8021494Sopenharmony_ciTEST(scvtf_ucvtf_float) { 4848b8021494Sopenharmony_ci // Simple conversions of positive numbers which require no rounding; the 4849b8021494Sopenharmony_ci // results should not depend on the rounding mode, and ucvtf and scvtf should 4850b8021494Sopenharmony_ci // produce the same result. 4851b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000000000000, 0x00000000, 0x00000000); 4852b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000000000001, 0x3f800000, 0x3f800000); 4853b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000040000000, 0x4e800000, 0x4e800000); 4854b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000100000000, 0x4f800000, 0x4f800000); 4855b8021494Sopenharmony_ci TestUScvtf32Helper(0x4000000000000000, 0x5e800000, 0x5e800000); 4856b8021494Sopenharmony_ci // Test mantissa extremities. 4857b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000000800001, 0x4b000001, 0x4b000001); 4858b8021494Sopenharmony_ci TestUScvtf32Helper(0x4000008000000000, 0x5e800001, 0x5e800001); 4859b8021494Sopenharmony_ci // The largest int32_t that fits in a float. 4860b8021494Sopenharmony_ci TestUScvtf32Helper(0x000000007fffff80, 0x4effffff, 0x4effffff); 4861b8021494Sopenharmony_ci // Values that would be negative if treated as an int32_t. 4862b8021494Sopenharmony_ci TestUScvtf32Helper(0x00000000ffffff00, 0x4f7fffff, 0x4f7fffff); 4863b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000080000000, 0x4f000000, 0x4f000000); 4864b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000080000100, 0x4f000001, 0x4f000001); 4865b8021494Sopenharmony_ci // The largest int64_t that fits in a float. 4866b8021494Sopenharmony_ci TestUScvtf32Helper(0x7fffff8000000000, 0x5effffff, 0x5effffff); 4867b8021494Sopenharmony_ci // Check for bit pattern reproduction. 4868b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000000000876543, 0x4b076543, 0x4b076543); 4869b8021494Sopenharmony_ci 4870b8021494Sopenharmony_ci // Simple conversions of negative int64_t values. These require no rounding, 4871b8021494Sopenharmony_ci // and the results should not depend on the rounding mode. 4872b8021494Sopenharmony_ci TestUScvtf32Helper(0xfffffc0000000000, 0xd4800000, 0x5f7ffffc); 4873b8021494Sopenharmony_ci TestUScvtf32Helper(0xc000000000000000, 0xde800000, 0x5f400000); 4874b8021494Sopenharmony_ci 4875b8021494Sopenharmony_ci // Conversions which require rounding. 4876b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800000000000, 0x57000000, 0x57000000); 4877b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800000000001, 0x57000000, 0x57000000); 4878b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800000800000, 0x57000000, 0x57000000); 4879b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800000800001, 0x57000001, 0x57000001); 4880b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800001000000, 0x57000001, 0x57000001); 4881b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800001000001, 0x57000001, 0x57000001); 4882b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800001800000, 0x57000002, 0x57000002); 4883b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800001800001, 0x57000002, 0x57000002); 4884b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800002000000, 0x57000002, 0x57000002); 4885b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800002000001, 0x57000002, 0x57000002); 4886b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800002800000, 0x57000002, 0x57000002); 4887b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800002800001, 0x57000003, 0x57000003); 4888b8021494Sopenharmony_ci TestUScvtf32Helper(0x0000800003000000, 0x57000003, 0x57000003); 4889b8021494Sopenharmony_ci // Check rounding of negative int64_t values (and large uint64_t values). 4890b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000000000000000, 0xdf000000, 0x5f000000); 4891b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000000000000001, 0xdf000000, 0x5f000000); 4892b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000004000000000, 0xdf000000, 0x5f000000); 4893b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000004000000001, 0xdeffffff, 0x5f000000); 4894b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000008000000000, 0xdeffffff, 0x5f000000); 4895b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000008000000001, 0xdeffffff, 0x5f000001); 4896b8021494Sopenharmony_ci TestUScvtf32Helper(0x800000c000000000, 0xdefffffe, 0x5f000001); 4897b8021494Sopenharmony_ci TestUScvtf32Helper(0x800000c000000001, 0xdefffffe, 0x5f000001); 4898b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000010000000000, 0xdefffffe, 0x5f000001); 4899b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000010000000001, 0xdefffffe, 0x5f000001); 4900b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000014000000000, 0xdefffffe, 0x5f000001); 4901b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000014000000001, 0xdefffffd, 0x5f000001); 4902b8021494Sopenharmony_ci TestUScvtf32Helper(0x8000018000000000, 0xdefffffd, 0x5f000002); 4903b8021494Sopenharmony_ci // Round up to produce a result that's too big for the input to represent. 4904b8021494Sopenharmony_ci TestUScvtf32Helper(0x000000007fffffc0, 0x4f000000, 0x4f000000); 4905b8021494Sopenharmony_ci TestUScvtf32Helper(0x000000007fffffff, 0x4f000000, 0x4f000000); 4906b8021494Sopenharmony_ci TestUScvtf32Helper(0x00000000ffffff80, 0x4f800000, 0x4f800000); 4907b8021494Sopenharmony_ci TestUScvtf32Helper(0x00000000ffffffff, 0x4f800000, 0x4f800000); 4908b8021494Sopenharmony_ci TestUScvtf32Helper(0x7fffffc000000000, 0x5f000000, 0x5f000000); 4909b8021494Sopenharmony_ci TestUScvtf32Helper(0x7fffffffffffffff, 0x5f000000, 0x5f000000); 4910b8021494Sopenharmony_ci TestUScvtf32Helper(0xffffff8000000000, 0xd3000000, 0x5f800000); 4911b8021494Sopenharmony_ci TestUScvtf32Helper(0xffffffffffffffff, 0xbf800000, 0x5f800000); 4912b8021494Sopenharmony_ci} 4913b8021494Sopenharmony_ci 4914b8021494Sopenharmony_ciTEST(process_nan_double) { 4915b8021494Sopenharmony_ci // Make sure that NaN propagation works correctly. 4916b8021494Sopenharmony_ci double sn = RawbitsToDouble(0x7ff5555511111111); 4917b8021494Sopenharmony_ci double qn = RawbitsToDouble(0x7ffaaaaa11111111); 4918b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sn)); 4919b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn)); 4920b8021494Sopenharmony_ci 4921b8021494Sopenharmony_ci // The input NaNs after passing through ProcessNaN. 4922b8021494Sopenharmony_ci double sn_proc = RawbitsToDouble(0x7ffd555511111111); 4923b8021494Sopenharmony_ci double qn_proc = qn; 4924b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sn_proc)); 4925b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn_proc)); 4926b8021494Sopenharmony_ci 4927b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 4928b8021494Sopenharmony_ci 4929b8021494Sopenharmony_ci START(); 4930b8021494Sopenharmony_ci 4931b8021494Sopenharmony_ci // Execute a number of instructions which all use ProcessNaN, and check that 4932b8021494Sopenharmony_ci // they all handle the NaN correctly. 4933b8021494Sopenharmony_ci __ Fmov(d0, sn); 4934b8021494Sopenharmony_ci __ Fmov(d10, qn); 4935b8021494Sopenharmony_ci 4936b8021494Sopenharmony_ci // Operations that always propagate NaNs unchanged, even signalling NaNs. 4937b8021494Sopenharmony_ci // - Signalling NaN 4938b8021494Sopenharmony_ci __ Fmov(d1, d0); 4939b8021494Sopenharmony_ci __ Fabs(d2, d0); 4940b8021494Sopenharmony_ci __ Fneg(d3, d0); 4941b8021494Sopenharmony_ci // - Quiet NaN 4942b8021494Sopenharmony_ci __ Fmov(d11, d10); 4943b8021494Sopenharmony_ci __ Fabs(d12, d10); 4944b8021494Sopenharmony_ci __ Fneg(d13, d10); 4945b8021494Sopenharmony_ci 4946b8021494Sopenharmony_ci // Operations that use ProcessNaN. 4947b8021494Sopenharmony_ci // - Signalling NaN 4948b8021494Sopenharmony_ci __ Fsqrt(d4, d0); 4949b8021494Sopenharmony_ci __ Frinta(d5, d0); 4950b8021494Sopenharmony_ci __ Frintn(d6, d0); 4951b8021494Sopenharmony_ci __ Frintz(d7, d0); 4952b8021494Sopenharmony_ci // - Quiet NaN 4953b8021494Sopenharmony_ci __ Fsqrt(d14, d10); 4954b8021494Sopenharmony_ci __ Frinta(d15, d10); 4955b8021494Sopenharmony_ci __ Frintn(d16, d10); 4956b8021494Sopenharmony_ci __ Frintz(d17, d10); 4957b8021494Sopenharmony_ci 4958b8021494Sopenharmony_ci // The behaviour of fcvt is checked in TEST(fcvt_sd). 4959b8021494Sopenharmony_ci 4960b8021494Sopenharmony_ci END(); 4961b8021494Sopenharmony_ci if (CAN_RUN()) { 4962b8021494Sopenharmony_ci RUN(); 4963b8021494Sopenharmony_ci 4964b8021494Sopenharmony_ci uint64_t qn_raw = DoubleToRawbits(qn); 4965b8021494Sopenharmony_ci uint64_t sn_raw = DoubleToRawbits(sn); 4966b8021494Sopenharmony_ci 4967b8021494Sopenharmony_ci // - Signalling NaN 4968b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(sn, d1); 4969b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(sn_raw & ~kDSignMask), d2); 4970b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(sn_raw ^ kDSignMask), d3); 4971b8021494Sopenharmony_ci // - Quiet NaN 4972b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(qn, d11); 4973b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(qn_raw & ~kDSignMask), d12); 4974b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(qn_raw ^ kDSignMask), d13); 4975b8021494Sopenharmony_ci 4976b8021494Sopenharmony_ci // - Signalling NaN 4977b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(sn_proc, d4); 4978b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(sn_proc, d5); 4979b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(sn_proc, d6); 4980b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(sn_proc, d7); 4981b8021494Sopenharmony_ci // - Quiet NaN 4982b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(qn_proc, d14); 4983b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(qn_proc, d15); 4984b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(qn_proc, d16); 4985b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(qn_proc, d17); 4986b8021494Sopenharmony_ci } 4987b8021494Sopenharmony_ci} 4988b8021494Sopenharmony_ci 4989b8021494Sopenharmony_ci 4990b8021494Sopenharmony_ciTEST(process_nan_float) { 4991b8021494Sopenharmony_ci // Make sure that NaN propagation works correctly. 4992b8021494Sopenharmony_ci float sn = RawbitsToFloat(0x7f951111); 4993b8021494Sopenharmony_ci float qn = RawbitsToFloat(0x7fea1111); 4994b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sn)); 4995b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn)); 4996b8021494Sopenharmony_ci 4997b8021494Sopenharmony_ci // The input NaNs after passing through ProcessNaN. 4998b8021494Sopenharmony_ci float sn_proc = RawbitsToFloat(0x7fd51111); 4999b8021494Sopenharmony_ci float qn_proc = qn; 5000b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sn_proc)); 5001b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn_proc)); 5002b8021494Sopenharmony_ci 5003b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 5004b8021494Sopenharmony_ci 5005b8021494Sopenharmony_ci START(); 5006b8021494Sopenharmony_ci 5007b8021494Sopenharmony_ci // Execute a number of instructions which all use ProcessNaN, and check that 5008b8021494Sopenharmony_ci // they all handle the NaN correctly. 5009b8021494Sopenharmony_ci __ Fmov(s0, sn); 5010b8021494Sopenharmony_ci __ Fmov(s10, qn); 5011b8021494Sopenharmony_ci 5012b8021494Sopenharmony_ci // Operations that always propagate NaNs unchanged, even signalling NaNs. 5013b8021494Sopenharmony_ci // - Signalling NaN 5014b8021494Sopenharmony_ci __ Fmov(s1, s0); 5015b8021494Sopenharmony_ci __ Fabs(s2, s0); 5016b8021494Sopenharmony_ci __ Fneg(s3, s0); 5017b8021494Sopenharmony_ci // - Quiet NaN 5018b8021494Sopenharmony_ci __ Fmov(s11, s10); 5019b8021494Sopenharmony_ci __ Fabs(s12, s10); 5020b8021494Sopenharmony_ci __ Fneg(s13, s10); 5021b8021494Sopenharmony_ci 5022b8021494Sopenharmony_ci // Operations that use ProcessNaN. 5023b8021494Sopenharmony_ci // - Signalling NaN 5024b8021494Sopenharmony_ci __ Fsqrt(s4, s0); 5025b8021494Sopenharmony_ci __ Frinta(s5, s0); 5026b8021494Sopenharmony_ci __ Frintn(s6, s0); 5027b8021494Sopenharmony_ci __ Frintz(s7, s0); 5028b8021494Sopenharmony_ci // - Quiet NaN 5029b8021494Sopenharmony_ci __ Fsqrt(s14, s10); 5030b8021494Sopenharmony_ci __ Frinta(s15, s10); 5031b8021494Sopenharmony_ci __ Frintn(s16, s10); 5032b8021494Sopenharmony_ci __ Frintz(s17, s10); 5033b8021494Sopenharmony_ci 5034b8021494Sopenharmony_ci // The behaviour of fcvt is checked in TEST(fcvt_sd). 5035b8021494Sopenharmony_ci 5036b8021494Sopenharmony_ci END(); 5037b8021494Sopenharmony_ci if (CAN_RUN()) { 5038b8021494Sopenharmony_ci RUN(); 5039b8021494Sopenharmony_ci 5040b8021494Sopenharmony_ci uint32_t qn_raw = FloatToRawbits(qn); 5041b8021494Sopenharmony_ci uint32_t sn_raw = FloatToRawbits(sn); 5042b8021494Sopenharmony_ci 5043b8021494Sopenharmony_ci // - Signalling NaN 5044b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(sn, s1); 5045b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(sn_raw & ~kSSignMask), s2); 5046b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(sn_raw ^ kSSignMask), s3); 5047b8021494Sopenharmony_ci // - Quiet NaN 5048b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(qn, s11); 5049b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(qn_raw & ~kSSignMask), s12); 5050b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(qn_raw ^ kSSignMask), s13); 5051b8021494Sopenharmony_ci 5052b8021494Sopenharmony_ci // - Signalling NaN 5053b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(sn_proc, s4); 5054b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(sn_proc, s5); 5055b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(sn_proc, s6); 5056b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(sn_proc, s7); 5057b8021494Sopenharmony_ci // - Quiet NaN 5058b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(qn_proc, s14); 5059b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(qn_proc, s15); 5060b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(qn_proc, s16); 5061b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(qn_proc, s17); 5062b8021494Sopenharmony_ci } 5063b8021494Sopenharmony_ci} 5064b8021494Sopenharmony_ci 5065b8021494Sopenharmony_ci// TODO: TEST(process_nan_half) {} 5066b8021494Sopenharmony_ci 5067b8021494Sopenharmony_cistatic void ProcessNaNsHelper(double n, double m, double expected) { 5068b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(n) || IsNaN(m)); 5069b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(expected)); 5070b8021494Sopenharmony_ci 5071b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 5072b8021494Sopenharmony_ci 5073b8021494Sopenharmony_ci START(); 5074b8021494Sopenharmony_ci 5075b8021494Sopenharmony_ci // Execute a number of instructions which all use ProcessNaNs, and check that 5076b8021494Sopenharmony_ci // they all propagate NaNs correctly. 5077b8021494Sopenharmony_ci __ Fmov(d0, n); 5078b8021494Sopenharmony_ci __ Fmov(d1, m); 5079b8021494Sopenharmony_ci 5080b8021494Sopenharmony_ci __ Fadd(d2, d0, d1); 5081b8021494Sopenharmony_ci __ Fsub(d3, d0, d1); 5082b8021494Sopenharmony_ci __ Fmul(d4, d0, d1); 5083b8021494Sopenharmony_ci __ Fdiv(d5, d0, d1); 5084b8021494Sopenharmony_ci __ Fmax(d6, d0, d1); 5085b8021494Sopenharmony_ci __ Fmin(d7, d0, d1); 5086b8021494Sopenharmony_ci 5087b8021494Sopenharmony_ci END(); 5088b8021494Sopenharmony_ci if (CAN_RUN()) { 5089b8021494Sopenharmony_ci RUN(); 5090b8021494Sopenharmony_ci 5091b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected, d2); 5092b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected, d3); 5093b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected, d4); 5094b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected, d5); 5095b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected, d6); 5096b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(expected, d7); 5097b8021494Sopenharmony_ci } 5098b8021494Sopenharmony_ci} 5099b8021494Sopenharmony_ci 5100b8021494Sopenharmony_ci 5101b8021494Sopenharmony_ciTEST(process_nans_double) { 5102b8021494Sopenharmony_ci // Make sure that NaN propagation works correctly. 5103b8021494Sopenharmony_ci double sn = RawbitsToDouble(0x7ff5555511111111); 5104b8021494Sopenharmony_ci double sm = RawbitsToDouble(0x7ff5555522222222); 5105b8021494Sopenharmony_ci double qn = RawbitsToDouble(0x7ffaaaaa11111111); 5106b8021494Sopenharmony_ci double qm = RawbitsToDouble(0x7ffaaaaa22222222); 5107b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sn)); 5108b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sm)); 5109b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn)); 5110b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm)); 5111b8021494Sopenharmony_ci 5112b8021494Sopenharmony_ci // The input NaNs after passing through ProcessNaN. 5113b8021494Sopenharmony_ci double sn_proc = RawbitsToDouble(0x7ffd555511111111); 5114b8021494Sopenharmony_ci double sm_proc = RawbitsToDouble(0x7ffd555522222222); 5115b8021494Sopenharmony_ci double qn_proc = qn; 5116b8021494Sopenharmony_ci double qm_proc = qm; 5117b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sn_proc)); 5118b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sm_proc)); 5119b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn_proc)); 5120b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm_proc)); 5121b8021494Sopenharmony_ci 5122b8021494Sopenharmony_ci // Quiet NaNs are propagated. 5123b8021494Sopenharmony_ci ProcessNaNsHelper(qn, 0, qn_proc); 5124b8021494Sopenharmony_ci ProcessNaNsHelper(0, qm, qm_proc); 5125b8021494Sopenharmony_ci ProcessNaNsHelper(qn, qm, qn_proc); 5126b8021494Sopenharmony_ci 5127b8021494Sopenharmony_ci // Signalling NaNs are propagated, and made quiet. 5128b8021494Sopenharmony_ci ProcessNaNsHelper(sn, 0, sn_proc); 5129b8021494Sopenharmony_ci ProcessNaNsHelper(0, sm, sm_proc); 5130b8021494Sopenharmony_ci ProcessNaNsHelper(sn, sm, sn_proc); 5131b8021494Sopenharmony_ci 5132b8021494Sopenharmony_ci // Signalling NaNs take precedence over quiet NaNs. 5133b8021494Sopenharmony_ci ProcessNaNsHelper(sn, qm, sn_proc); 5134b8021494Sopenharmony_ci ProcessNaNsHelper(qn, sm, sm_proc); 5135b8021494Sopenharmony_ci ProcessNaNsHelper(sn, sm, sn_proc); 5136b8021494Sopenharmony_ci} 5137b8021494Sopenharmony_ci 5138b8021494Sopenharmony_ci 5139b8021494Sopenharmony_cistatic void ProcessNaNsHelper(float n, float m, float expected) { 5140b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(n) || IsNaN(m)); 5141b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(expected)); 5142b8021494Sopenharmony_ci 5143b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 5144b8021494Sopenharmony_ci 5145b8021494Sopenharmony_ci START(); 5146b8021494Sopenharmony_ci 5147b8021494Sopenharmony_ci // Execute a number of instructions which all use ProcessNaNs, and check that 5148b8021494Sopenharmony_ci // they all propagate NaNs correctly. 5149b8021494Sopenharmony_ci __ Fmov(s0, n); 5150b8021494Sopenharmony_ci __ Fmov(s1, m); 5151b8021494Sopenharmony_ci 5152b8021494Sopenharmony_ci __ Fadd(s2, s0, s1); 5153b8021494Sopenharmony_ci __ Fsub(s3, s0, s1); 5154b8021494Sopenharmony_ci __ Fmul(s4, s0, s1); 5155b8021494Sopenharmony_ci __ Fdiv(s5, s0, s1); 5156b8021494Sopenharmony_ci __ Fmax(s6, s0, s1); 5157b8021494Sopenharmony_ci __ Fmin(s7, s0, s1); 5158b8021494Sopenharmony_ci 5159b8021494Sopenharmony_ci END(); 5160b8021494Sopenharmony_ci if (CAN_RUN()) { 5161b8021494Sopenharmony_ci RUN(); 5162b8021494Sopenharmony_ci 5163b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected, s2); 5164b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected, s3); 5165b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected, s4); 5166b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected, s5); 5167b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected, s6); 5168b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(expected, s7); 5169b8021494Sopenharmony_ci } 5170b8021494Sopenharmony_ci} 5171b8021494Sopenharmony_ci 5172b8021494Sopenharmony_ci 5173b8021494Sopenharmony_ciTEST(process_nans_float) { 5174b8021494Sopenharmony_ci // Make sure that NaN propagation works correctly. 5175b8021494Sopenharmony_ci float sn = RawbitsToFloat(0x7f951111); 5176b8021494Sopenharmony_ci float sm = RawbitsToFloat(0x7f952222); 5177b8021494Sopenharmony_ci float qn = RawbitsToFloat(0x7fea1111); 5178b8021494Sopenharmony_ci float qm = RawbitsToFloat(0x7fea2222); 5179b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sn)); 5180b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sm)); 5181b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn)); 5182b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm)); 5183b8021494Sopenharmony_ci 5184b8021494Sopenharmony_ci // The input NaNs after passing through ProcessNaN. 5185b8021494Sopenharmony_ci float sn_proc = RawbitsToFloat(0x7fd51111); 5186b8021494Sopenharmony_ci float sm_proc = RawbitsToFloat(0x7fd52222); 5187b8021494Sopenharmony_ci float qn_proc = qn; 5188b8021494Sopenharmony_ci float qm_proc = qm; 5189b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sn_proc)); 5190b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sm_proc)); 5191b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn_proc)); 5192b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm_proc)); 5193b8021494Sopenharmony_ci 5194b8021494Sopenharmony_ci // Quiet NaNs are propagated. 5195b8021494Sopenharmony_ci ProcessNaNsHelper(qn, 0, qn_proc); 5196b8021494Sopenharmony_ci ProcessNaNsHelper(0, qm, qm_proc); 5197b8021494Sopenharmony_ci ProcessNaNsHelper(qn, qm, qn_proc); 5198b8021494Sopenharmony_ci 5199b8021494Sopenharmony_ci // Signalling NaNs are propagated, and made quiet. 5200b8021494Sopenharmony_ci ProcessNaNsHelper(sn, 0, sn_proc); 5201b8021494Sopenharmony_ci ProcessNaNsHelper(0, sm, sm_proc); 5202b8021494Sopenharmony_ci ProcessNaNsHelper(sn, sm, sn_proc); 5203b8021494Sopenharmony_ci 5204b8021494Sopenharmony_ci // Signalling NaNs take precedence over quiet NaNs. 5205b8021494Sopenharmony_ci ProcessNaNsHelper(sn, qm, sn_proc); 5206b8021494Sopenharmony_ci ProcessNaNsHelper(qn, sm, sm_proc); 5207b8021494Sopenharmony_ci ProcessNaNsHelper(sn, sm, sn_proc); 5208b8021494Sopenharmony_ci} 5209b8021494Sopenharmony_ci 5210b8021494Sopenharmony_ci 5211b8021494Sopenharmony_cistatic void ProcessNaNsHelper(Float16 n, Float16 m, Float16 expected) { 5212b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(n) || IsNaN(m)); 5213b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(expected)); 5214b8021494Sopenharmony_ci 5215b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP, CPUFeatures::kFPHalf); 5216b8021494Sopenharmony_ci 5217b8021494Sopenharmony_ci START(); 5218b8021494Sopenharmony_ci 5219b8021494Sopenharmony_ci // Execute a number of instructions which all use ProcessNaNs, and check that 5220b8021494Sopenharmony_ci // they all propagate NaNs correctly. 5221b8021494Sopenharmony_ci __ Fmov(h0, n); 5222b8021494Sopenharmony_ci __ Fmov(h1, m); 5223b8021494Sopenharmony_ci 5224b8021494Sopenharmony_ci __ Fadd(h2, h0, h1); 5225b8021494Sopenharmony_ci __ Fsub(h3, h0, h1); 5226b8021494Sopenharmony_ci __ Fmul(h4, h0, h1); 5227b8021494Sopenharmony_ci __ Fdiv(h5, h0, h1); 5228b8021494Sopenharmony_ci __ Fmax(h6, h0, h1); 5229b8021494Sopenharmony_ci __ Fmin(h7, h0, h1); 5230b8021494Sopenharmony_ci 5231b8021494Sopenharmony_ci END(); 5232b8021494Sopenharmony_ci 5233b8021494Sopenharmony_ci if (CAN_RUN()) { 5234b8021494Sopenharmony_ci RUN(); 5235b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(expected, h2); 5236b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(expected, h3); 5237b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(expected, h4); 5238b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(expected, h5); 5239b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(expected, h6); 5240b8021494Sopenharmony_ci ASSERT_EQUAL_FP16(expected, h7); 5241b8021494Sopenharmony_ci } 5242b8021494Sopenharmony_ci} 5243b8021494Sopenharmony_ci 5244b8021494Sopenharmony_ci 5245b8021494Sopenharmony_ciTEST(process_nans_half) { 5246b8021494Sopenharmony_ci // Make sure that NaN propagation works correctly. 5247b8021494Sopenharmony_ci Float16 sn(RawbitsToFloat16(0x7c11)); 5248b8021494Sopenharmony_ci Float16 sm(RawbitsToFloat16(0xfc22)); 5249b8021494Sopenharmony_ci Float16 qn(RawbitsToFloat16(0x7e33)); 5250b8021494Sopenharmony_ci Float16 qm(RawbitsToFloat16(0xfe44)); 5251b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sn)); 5252b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sm)); 5253b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn)); 5254b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm)); 5255b8021494Sopenharmony_ci 5256b8021494Sopenharmony_ci // The input NaNs after passing through ProcessNaN. 5257b8021494Sopenharmony_ci Float16 sn_proc(RawbitsToFloat16(0x7e11)); 5258b8021494Sopenharmony_ci Float16 sm_proc(RawbitsToFloat16(0xfe22)); 5259b8021494Sopenharmony_ci Float16 qn_proc = qn; 5260b8021494Sopenharmony_ci Float16 qm_proc = qm; 5261b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sn_proc)); 5262b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(sm_proc)); 5263b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn_proc)); 5264b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm_proc)); 5265b8021494Sopenharmony_ci 5266b8021494Sopenharmony_ci // Quiet NaNs are propagated. 5267b8021494Sopenharmony_ci ProcessNaNsHelper(qn, Float16(), qn_proc); 5268b8021494Sopenharmony_ci ProcessNaNsHelper(Float16(), qm, qm_proc); 5269b8021494Sopenharmony_ci ProcessNaNsHelper(qn, qm, qn_proc); 5270b8021494Sopenharmony_ci 5271b8021494Sopenharmony_ci // Signalling NaNs are propagated, and made quiet. 5272b8021494Sopenharmony_ci ProcessNaNsHelper(sn, Float16(), sn_proc); 5273b8021494Sopenharmony_ci ProcessNaNsHelper(Float16(), sm, sm_proc); 5274b8021494Sopenharmony_ci ProcessNaNsHelper(sn, sm, sn_proc); 5275b8021494Sopenharmony_ci 5276b8021494Sopenharmony_ci // Signalling NaNs take precedence over quiet NaNs. 5277b8021494Sopenharmony_ci ProcessNaNsHelper(sn, qm, sn_proc); 5278b8021494Sopenharmony_ci ProcessNaNsHelper(qn, sm, sm_proc); 5279b8021494Sopenharmony_ci ProcessNaNsHelper(sn, sm, sn_proc); 5280b8021494Sopenharmony_ci} 5281b8021494Sopenharmony_ci 5282b8021494Sopenharmony_ci 5283b8021494Sopenharmony_cistatic void DefaultNaNHelper(float n, float m, float a) { 5284b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(n) || IsNaN(m) || IsNaN(a)); 5285b8021494Sopenharmony_ci 5286b8021494Sopenharmony_ci bool test_1op = IsNaN(n); 5287b8021494Sopenharmony_ci bool test_2op = IsNaN(n) || IsNaN(m); 5288b8021494Sopenharmony_ci 5289b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 5290b8021494Sopenharmony_ci START(); 5291b8021494Sopenharmony_ci 5292b8021494Sopenharmony_ci // Enable Default-NaN mode in the FPCR. 5293b8021494Sopenharmony_ci __ Mrs(x0, FPCR); 5294b8021494Sopenharmony_ci __ Orr(x1, x0, DN_mask); 5295b8021494Sopenharmony_ci __ Msr(FPCR, x1); 5296b8021494Sopenharmony_ci 5297b8021494Sopenharmony_ci // Execute a number of instructions which all use ProcessNaNs, and check that 5298b8021494Sopenharmony_ci // they all produce the default NaN. 5299b8021494Sopenharmony_ci __ Fmov(s0, n); 5300b8021494Sopenharmony_ci __ Fmov(s1, m); 5301b8021494Sopenharmony_ci __ Fmov(s2, a); 5302b8021494Sopenharmony_ci 5303b8021494Sopenharmony_ci if (test_1op) { 5304b8021494Sopenharmony_ci // Operations that always propagate NaNs unchanged, even signalling NaNs. 5305b8021494Sopenharmony_ci __ Fmov(s10, s0); 5306b8021494Sopenharmony_ci __ Fabs(s11, s0); 5307b8021494Sopenharmony_ci __ Fneg(s12, s0); 5308b8021494Sopenharmony_ci 5309b8021494Sopenharmony_ci // Operations that use ProcessNaN. 5310b8021494Sopenharmony_ci __ Fsqrt(s13, s0); 5311b8021494Sopenharmony_ci __ Frinta(s14, s0); 5312b8021494Sopenharmony_ci __ Frintn(s15, s0); 5313b8021494Sopenharmony_ci __ Frintz(s16, s0); 5314b8021494Sopenharmony_ci 5315b8021494Sopenharmony_ci // Fcvt usually has special NaN handling, but it respects default-NaN mode. 5316b8021494Sopenharmony_ci __ Fcvt(d17, s0); 5317b8021494Sopenharmony_ci } 5318b8021494Sopenharmony_ci 5319b8021494Sopenharmony_ci if (test_2op) { 5320b8021494Sopenharmony_ci __ Fadd(s18, s0, s1); 5321b8021494Sopenharmony_ci __ Fsub(s19, s0, s1); 5322b8021494Sopenharmony_ci __ Fmul(s20, s0, s1); 5323b8021494Sopenharmony_ci __ Fdiv(s21, s0, s1); 5324b8021494Sopenharmony_ci __ Fmax(s22, s0, s1); 5325b8021494Sopenharmony_ci __ Fmin(s23, s0, s1); 5326b8021494Sopenharmony_ci } 5327b8021494Sopenharmony_ci 5328b8021494Sopenharmony_ci __ Fmadd(s24, s0, s1, s2); 5329b8021494Sopenharmony_ci __ Fmsub(s25, s0, s1, s2); 5330b8021494Sopenharmony_ci __ Fnmadd(s26, s0, s1, s2); 5331b8021494Sopenharmony_ci __ Fnmsub(s27, s0, s1, s2); 5332b8021494Sopenharmony_ci 5333b8021494Sopenharmony_ci // Restore FPCR. 5334b8021494Sopenharmony_ci __ Msr(FPCR, x0); 5335b8021494Sopenharmony_ci 5336b8021494Sopenharmony_ci END(); 5337b8021494Sopenharmony_ci if (CAN_RUN()) { 5338b8021494Sopenharmony_ci RUN(); 5339b8021494Sopenharmony_ci 5340b8021494Sopenharmony_ci if (test_1op) { 5341b8021494Sopenharmony_ci uint32_t n_raw = FloatToRawbits(n); 5342b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(n, s10); 5343b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(n_raw & ~kSSignMask), s11); 5344b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(RawbitsToFloat(n_raw ^ kSSignMask), s12); 5345b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s13); 5346b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s14); 5347b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s15); 5348b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s16); 5349b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d17); 5350b8021494Sopenharmony_ci } 5351b8021494Sopenharmony_ci 5352b8021494Sopenharmony_ci if (test_2op) { 5353b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s18); 5354b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s19); 5355b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s20); 5356b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s21); 5357b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s22); 5358b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s23); 5359b8021494Sopenharmony_ci } 5360b8021494Sopenharmony_ci 5361b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s24); 5362b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s25); 5363b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s26); 5364b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s27); 5365b8021494Sopenharmony_ci } 5366b8021494Sopenharmony_ci} 5367b8021494Sopenharmony_ci 5368b8021494Sopenharmony_ci 5369b8021494Sopenharmony_ciTEST(default_nan_float) { 5370b8021494Sopenharmony_ci float sn = RawbitsToFloat(0x7f951111); 5371b8021494Sopenharmony_ci float sm = RawbitsToFloat(0x7f952222); 5372b8021494Sopenharmony_ci float sa = RawbitsToFloat(0x7f95aaaa); 5373b8021494Sopenharmony_ci float qn = RawbitsToFloat(0x7fea1111); 5374b8021494Sopenharmony_ci float qm = RawbitsToFloat(0x7fea2222); 5375b8021494Sopenharmony_ci float qa = RawbitsToFloat(0x7feaaaaa); 5376b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sn)); 5377b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sm)); 5378b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sa)); 5379b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn)); 5380b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm)); 5381b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qa)); 5382b8021494Sopenharmony_ci 5383b8021494Sopenharmony_ci // - Signalling NaNs 5384b8021494Sopenharmony_ci DefaultNaNHelper(sn, 0.0f, 0.0f); 5385b8021494Sopenharmony_ci DefaultNaNHelper(0.0f, sm, 0.0f); 5386b8021494Sopenharmony_ci DefaultNaNHelper(0.0f, 0.0f, sa); 5387b8021494Sopenharmony_ci DefaultNaNHelper(sn, sm, 0.0f); 5388b8021494Sopenharmony_ci DefaultNaNHelper(0.0f, sm, sa); 5389b8021494Sopenharmony_ci DefaultNaNHelper(sn, 0.0f, sa); 5390b8021494Sopenharmony_ci DefaultNaNHelper(sn, sm, sa); 5391b8021494Sopenharmony_ci // - Quiet NaNs 5392b8021494Sopenharmony_ci DefaultNaNHelper(qn, 0.0f, 0.0f); 5393b8021494Sopenharmony_ci DefaultNaNHelper(0.0f, qm, 0.0f); 5394b8021494Sopenharmony_ci DefaultNaNHelper(0.0f, 0.0f, qa); 5395b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, 0.0f); 5396b8021494Sopenharmony_ci DefaultNaNHelper(0.0f, qm, qa); 5397b8021494Sopenharmony_ci DefaultNaNHelper(qn, 0.0f, qa); 5398b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, qa); 5399b8021494Sopenharmony_ci // - Mixed NaNs 5400b8021494Sopenharmony_ci DefaultNaNHelper(qn, sm, sa); 5401b8021494Sopenharmony_ci DefaultNaNHelper(sn, qm, sa); 5402b8021494Sopenharmony_ci DefaultNaNHelper(sn, sm, qa); 5403b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, sa); 5404b8021494Sopenharmony_ci DefaultNaNHelper(sn, qm, qa); 5405b8021494Sopenharmony_ci DefaultNaNHelper(qn, sm, qa); 5406b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, qa); 5407b8021494Sopenharmony_ci} 5408b8021494Sopenharmony_ci 5409b8021494Sopenharmony_ci 5410b8021494Sopenharmony_cistatic void DefaultNaNHelper(double n, double m, double a) { 5411b8021494Sopenharmony_ci VIXL_ASSERT(IsNaN(n) || IsNaN(m) || IsNaN(a)); 5412b8021494Sopenharmony_ci 5413b8021494Sopenharmony_ci bool test_1op = IsNaN(n); 5414b8021494Sopenharmony_ci bool test_2op = IsNaN(n) || IsNaN(m); 5415b8021494Sopenharmony_ci 5416b8021494Sopenharmony_ci SETUP_WITH_FEATURES(CPUFeatures::kFP); 5417b8021494Sopenharmony_ci 5418b8021494Sopenharmony_ci START(); 5419b8021494Sopenharmony_ci 5420b8021494Sopenharmony_ci // Enable Default-NaN mode in the FPCR. 5421b8021494Sopenharmony_ci __ Mrs(x0, FPCR); 5422b8021494Sopenharmony_ci __ Orr(x1, x0, DN_mask); 5423b8021494Sopenharmony_ci __ Msr(FPCR, x1); 5424b8021494Sopenharmony_ci 5425b8021494Sopenharmony_ci // Execute a number of instructions which all use ProcessNaNs, and check that 5426b8021494Sopenharmony_ci // they all produce the default NaN. 5427b8021494Sopenharmony_ci __ Fmov(d0, n); 5428b8021494Sopenharmony_ci __ Fmov(d1, m); 5429b8021494Sopenharmony_ci __ Fmov(d2, a); 5430b8021494Sopenharmony_ci 5431b8021494Sopenharmony_ci if (test_1op) { 5432b8021494Sopenharmony_ci // Operations that always propagate NaNs unchanged, even signalling NaNs. 5433b8021494Sopenharmony_ci __ Fmov(d10, d0); 5434b8021494Sopenharmony_ci __ Fabs(d11, d0); 5435b8021494Sopenharmony_ci __ Fneg(d12, d0); 5436b8021494Sopenharmony_ci 5437b8021494Sopenharmony_ci // Operations that use ProcessNaN. 5438b8021494Sopenharmony_ci __ Fsqrt(d13, d0); 5439b8021494Sopenharmony_ci __ Frinta(d14, d0); 5440b8021494Sopenharmony_ci __ Frintn(d15, d0); 5441b8021494Sopenharmony_ci __ Frintz(d16, d0); 5442b8021494Sopenharmony_ci 5443b8021494Sopenharmony_ci // Fcvt usually has special NaN handling, but it respects default-NaN mode. 5444b8021494Sopenharmony_ci __ Fcvt(s17, d0); 5445b8021494Sopenharmony_ci } 5446b8021494Sopenharmony_ci 5447b8021494Sopenharmony_ci if (test_2op) { 5448b8021494Sopenharmony_ci __ Fadd(d18, d0, d1); 5449b8021494Sopenharmony_ci __ Fsub(d19, d0, d1); 5450b8021494Sopenharmony_ci __ Fmul(d20, d0, d1); 5451b8021494Sopenharmony_ci __ Fdiv(d21, d0, d1); 5452b8021494Sopenharmony_ci __ Fmax(d22, d0, d1); 5453b8021494Sopenharmony_ci __ Fmin(d23, d0, d1); 5454b8021494Sopenharmony_ci } 5455b8021494Sopenharmony_ci 5456b8021494Sopenharmony_ci __ Fmadd(d24, d0, d1, d2); 5457b8021494Sopenharmony_ci __ Fmsub(d25, d0, d1, d2); 5458b8021494Sopenharmony_ci __ Fnmadd(d26, d0, d1, d2); 5459b8021494Sopenharmony_ci __ Fnmsub(d27, d0, d1, d2); 5460b8021494Sopenharmony_ci 5461b8021494Sopenharmony_ci // Restore FPCR. 5462b8021494Sopenharmony_ci __ Msr(FPCR, x0); 5463b8021494Sopenharmony_ci 5464b8021494Sopenharmony_ci END(); 5465b8021494Sopenharmony_ci if (CAN_RUN()) { 5466b8021494Sopenharmony_ci RUN(); 5467b8021494Sopenharmony_ci 5468b8021494Sopenharmony_ci if (test_1op) { 5469b8021494Sopenharmony_ci uint64_t n_raw = DoubleToRawbits(n); 5470b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(n, d10); 5471b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(n_raw & ~kDSignMask), d11); 5472b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(RawbitsToDouble(n_raw ^ kDSignMask), d12); 5473b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d13); 5474b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d14); 5475b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d15); 5476b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d16); 5477b8021494Sopenharmony_ci ASSERT_EQUAL_FP32(kFP32DefaultNaN, s17); 5478b8021494Sopenharmony_ci } 5479b8021494Sopenharmony_ci 5480b8021494Sopenharmony_ci if (test_2op) { 5481b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d18); 5482b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d19); 5483b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d20); 5484b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d21); 5485b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d22); 5486b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d23); 5487b8021494Sopenharmony_ci } 5488b8021494Sopenharmony_ci 5489b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d24); 5490b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d25); 5491b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d26); 5492b8021494Sopenharmony_ci ASSERT_EQUAL_FP64(kFP64DefaultNaN, d27); 5493b8021494Sopenharmony_ci } 5494b8021494Sopenharmony_ci} 5495b8021494Sopenharmony_ci 5496b8021494Sopenharmony_ci 5497b8021494Sopenharmony_ciTEST(default_nan_double) { 5498b8021494Sopenharmony_ci double sn = RawbitsToDouble(0x7ff5555511111111); 5499b8021494Sopenharmony_ci double sm = RawbitsToDouble(0x7ff5555522222222); 5500b8021494Sopenharmony_ci double sa = RawbitsToDouble(0x7ff55555aaaaaaaa); 5501b8021494Sopenharmony_ci double qn = RawbitsToDouble(0x7ffaaaaa11111111); 5502b8021494Sopenharmony_ci double qm = RawbitsToDouble(0x7ffaaaaa22222222); 5503b8021494Sopenharmony_ci double qa = RawbitsToDouble(0x7ffaaaaaaaaaaaaa); 5504b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sn)); 5505b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sm)); 5506b8021494Sopenharmony_ci VIXL_ASSERT(IsSignallingNaN(sa)); 5507b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qn)); 5508b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qm)); 5509b8021494Sopenharmony_ci VIXL_ASSERT(IsQuietNaN(qa)); 5510b8021494Sopenharmony_ci 5511b8021494Sopenharmony_ci // - Signalling NaNs 5512b8021494Sopenharmony_ci DefaultNaNHelper(sn, 0.0, 0.0); 5513b8021494Sopenharmony_ci DefaultNaNHelper(0.0, sm, 0.0); 5514b8021494Sopenharmony_ci DefaultNaNHelper(0.0, 0.0, sa); 5515b8021494Sopenharmony_ci DefaultNaNHelper(sn, sm, 0.0); 5516b8021494Sopenharmony_ci DefaultNaNHelper(0.0, sm, sa); 5517b8021494Sopenharmony_ci DefaultNaNHelper(sn, 0.0, sa); 5518b8021494Sopenharmony_ci DefaultNaNHelper(sn, sm, sa); 5519b8021494Sopenharmony_ci // - Quiet NaNs 5520b8021494Sopenharmony_ci DefaultNaNHelper(qn, 0.0, 0.0); 5521b8021494Sopenharmony_ci DefaultNaNHelper(0.0, qm, 0.0); 5522b8021494Sopenharmony_ci DefaultNaNHelper(0.0, 0.0, qa); 5523b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, 0.0); 5524b8021494Sopenharmony_ci DefaultNaNHelper(0.0, qm, qa); 5525b8021494Sopenharmony_ci DefaultNaNHelper(qn, 0.0, qa); 5526b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, qa); 5527b8021494Sopenharmony_ci // - Mixed NaNs 5528b8021494Sopenharmony_ci DefaultNaNHelper(qn, sm, sa); 5529b8021494Sopenharmony_ci DefaultNaNHelper(sn, qm, sa); 5530b8021494Sopenharmony_ci DefaultNaNHelper(sn, sm, qa); 5531b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, sa); 5532b8021494Sopenharmony_ci DefaultNaNHelper(sn, qm, qa); 5533b8021494Sopenharmony_ci DefaultNaNHelper(qn, sm, qa); 5534b8021494Sopenharmony_ci DefaultNaNHelper(qn, qm, qa); 5535b8021494Sopenharmony_ci} 5536b8021494Sopenharmony_ci 5537b8021494Sopenharmony_ci} // namespace aarch64 5538b8021494Sopenharmony_ci} // namespace vixl 5539