Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: test/cctest/test-assembler-arm.cc

Issue 1862993002: [arm] Implement Float(32|64)(Min|Max) using vsel. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/arm/instruction-selector-arm.cc ('k') | test/cctest/test-disasm-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.ar)); 2224 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.ar));
2225 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.nr)); 2225 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.nr));
2226 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.mr)); 2226 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.mr));
2227 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.pr)); 2227 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.pr));
2228 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.zr)); 2228 CHECK_EQ(bit_cast<int64_t>(nan), bit_cast<int64_t>(t.zr));
2229 2229
2230 #undef CHECK_VRINT 2230 #undef CHECK_VRINT
2231 } 2231 }
2232 } 2232 }
2233 2233
2234 TEST(ARMv8_vsel) {
2235 // Test the vsel floating point instructions.
2236 CcTest::InitializeVM();
2237 Isolate* isolate = CcTest::i_isolate();
2238 HandleScope scope(isolate);
2239
2240 Assembler assm(isolate, NULL, 0);
2241
2242 // Used to indicate whether a condition passed or failed.
2243 static constexpr float kResultPass = 1.0f;
2244 static constexpr float kResultFail = -kResultPass;
2245
2246 struct ResultsF32 {
2247 float vseleq_;
2248 float vselge_;
2249 float vselgt_;
2250 float vselvs_;
2251
2252 // The following conditions aren't architecturally supported, but the
2253 // assembler implements them by swapping the inputs.
2254 float vselne_;
2255 float vsellt_;
2256 float vselle_;
2257 float vselvc_;
2258 };
2259
2260 struct ResultsF64 {
2261 double vseleq_;
2262 double vselge_;
2263 double vselgt_;
2264 double vselvs_;
2265
2266 // The following conditions aren't architecturally supported, but the
2267 // assembler implements them by swapping the inputs.
2268 double vselne_;
2269 double vsellt_;
2270 double vselle_;
2271 double vselvc_;
2272 };
2273
2274 if (CpuFeatures::IsSupported(ARMv8)) {
2275 CpuFeatureScope scope(&assm, ARMv8);
2276
2277 // Create a helper function:
2278 // void TestVsel(uint32_t nzcv,
2279 // ResultsF32* results_f32,
2280 // ResultsF64* results_f64);
2281 __ msr(CPSR_f, Operand(r0));
2282
2283 __ vmov(s1, kResultPass);
2284 __ vmov(s2, kResultFail);
2285
2286 __ vsel(eq, s0, s1, s2);
2287 __ vstr(s0, r1, offsetof(ResultsF32, vseleq_));
2288 __ vsel(ge, s0, s1, s2);
2289 __ vstr(s0, r1, offsetof(ResultsF32, vselge_));
2290 __ vsel(gt, s0, s1, s2);
2291 __ vstr(s0, r1, offsetof(ResultsF32, vselgt_));
2292 __ vsel(vs, s0, s1, s2);
2293 __ vstr(s0, r1, offsetof(ResultsF32, vselvs_));
2294
2295 __ vsel(ne, s0, s1, s2);
2296 __ vstr(s0, r1, offsetof(ResultsF32, vselne_));
2297 __ vsel(lt, s0, s1, s2);
2298 __ vstr(s0, r1, offsetof(ResultsF32, vsellt_));
2299 __ vsel(le, s0, s1, s2);
2300 __ vstr(s0, r1, offsetof(ResultsF32, vselle_));
2301 __ vsel(vc, s0, s1, s2);
2302 __ vstr(s0, r1, offsetof(ResultsF32, vselvc_));
2303
2304 __ vmov(d1, kResultPass);
2305 __ vmov(d2, kResultFail);
2306
2307 __ vsel(eq, d0, d1, d2);
2308 __ vstr(d0, r2, offsetof(ResultsF64, vseleq_));
2309 __ vsel(ge, d0, d1, d2);
2310 __ vstr(d0, r2, offsetof(ResultsF64, vselge_));
2311 __ vsel(gt, d0, d1, d2);
2312 __ vstr(d0, r2, offsetof(ResultsF64, vselgt_));
2313 __ vsel(vs, d0, d1, d2);
2314 __ vstr(d0, r2, offsetof(ResultsF64, vselvs_));
2315
2316 __ vsel(ne, d0, d1, d2);
2317 __ vstr(d0, r2, offsetof(ResultsF64, vselne_));
2318 __ vsel(lt, d0, d1, d2);
2319 __ vstr(d0, r2, offsetof(ResultsF64, vsellt_));
2320 __ vsel(le, d0, d1, d2);
2321 __ vstr(d0, r2, offsetof(ResultsF64, vselle_));
2322 __ vsel(vc, d0, d1, d2);
2323 __ vstr(d0, r2, offsetof(ResultsF64, vselvc_));
2324
2325 __ bx(lr);
2326
2327 CodeDesc desc;
2328 assm.GetCode(&desc);
2329 Handle<Code> code = isolate->factory()->NewCode(
2330 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2331 #ifdef DEBUG
2332 OFStream os(stdout);
2333 code->Print(os);
2334 #endif
2335 F5 f = FUNCTION_CAST<F5>(code->entry());
2336 Object* dummy = nullptr;
2337 USE(dummy);
2338
2339 STATIC_ASSERT(kResultPass == -kResultFail);
2340 #define CHECK_VSEL(n, z, c, v, vseleq, vselge, vselgt, vselvs) \
2341 do { \
2342 ResultsF32 results_f32; \
2343 ResultsF64 results_f64; \
2344 uint32_t nzcv = (n << 31) | (z << 30) | (c << 29) | (v << 28); \
2345 dummy = CALL_GENERATED_CODE(isolate, f, nzcv, &results_f32, &results_f64, \
2346 0, 0); \
2347 CHECK_EQ(vseleq, results_f32.vseleq_); \
2348 CHECK_EQ(vselge, results_f32.vselge_); \
2349 CHECK_EQ(vselgt, results_f32.vselgt_); \
2350 CHECK_EQ(vselvs, results_f32.vselvs_); \
2351 CHECK_EQ(-vseleq, results_f32.vselne_); \
2352 CHECK_EQ(-vselge, results_f32.vsellt_); \
2353 CHECK_EQ(-vselgt, results_f32.vselle_); \
2354 CHECK_EQ(-vselvs, results_f32.vselvc_); \
2355 CHECK_EQ(vseleq, results_f64.vseleq_); \
2356 CHECK_EQ(vselge, results_f64.vselge_); \
2357 CHECK_EQ(vselgt, results_f64.vselgt_); \
2358 CHECK_EQ(vselvs, results_f64.vselvs_); \
2359 CHECK_EQ(-vseleq, results_f64.vselne_); \
2360 CHECK_EQ(-vselge, results_f64.vsellt_); \
2361 CHECK_EQ(-vselgt, results_f64.vselle_); \
2362 CHECK_EQ(-vselvs, results_f64.vselvc_); \
2363 } while (0);
2364
2365 // N Z C V vseleq vselge vselgt vselvs
2366 CHECK_VSEL(0, 0, 0, 0, kResultFail, kResultPass, kResultPass, kResultFail);
2367 CHECK_VSEL(0, 0, 0, 1, kResultFail, kResultFail, kResultFail, kResultPass);
2368 CHECK_VSEL(0, 0, 1, 0, kResultFail, kResultPass, kResultPass, kResultFail);
2369 CHECK_VSEL(0, 0, 1, 1, kResultFail, kResultFail, kResultFail, kResultPass);
2370 CHECK_VSEL(0, 1, 0, 0, kResultPass, kResultPass, kResultFail, kResultFail);
2371 CHECK_VSEL(0, 1, 0, 1, kResultPass, kResultFail, kResultFail, kResultPass);
2372 CHECK_VSEL(0, 1, 1, 0, kResultPass, kResultPass, kResultFail, kResultFail);
2373 CHECK_VSEL(0, 1, 1, 1, kResultPass, kResultFail, kResultFail, kResultPass);
2374 CHECK_VSEL(1, 0, 0, 0, kResultFail, kResultFail, kResultFail, kResultFail);
2375 CHECK_VSEL(1, 0, 0, 1, kResultFail, kResultPass, kResultPass, kResultPass);
2376 CHECK_VSEL(1, 0, 1, 0, kResultFail, kResultFail, kResultFail, kResultFail);
2377 CHECK_VSEL(1, 0, 1, 1, kResultFail, kResultPass, kResultPass, kResultPass);
2378 CHECK_VSEL(1, 1, 0, 0, kResultPass, kResultFail, kResultFail, kResultFail);
2379 CHECK_VSEL(1, 1, 0, 1, kResultPass, kResultPass, kResultFail, kResultPass);
2380 CHECK_VSEL(1, 1, 1, 0, kResultPass, kResultFail, kResultFail, kResultFail);
2381 CHECK_VSEL(1, 1, 1, 1, kResultPass, kResultPass, kResultFail, kResultPass);
2382
2383 #undef CHECK_VSEL
2384 }
2385 }
2234 2386
2235 TEST(regress4292_b) { 2387 TEST(regress4292_b) {
2236 CcTest::InitializeVM(); 2388 CcTest::InitializeVM();
2237 Isolate* isolate = CcTest::i_isolate(); 2389 Isolate* isolate = CcTest::i_isolate();
2238 HandleScope scope(isolate); 2390 HandleScope scope(isolate);
2239 2391
2240 Assembler assm(isolate, NULL, 0); 2392 Assembler assm(isolate, NULL, 0);
2241 Label end; 2393 Label end;
2242 __ mov(r0, Operand(isolate->factory()->infinity_value())); 2394 __ mov(r0, Operand(isolate->factory()->infinity_value()));
2243 for (int i = 0; i < 1020; ++i) { 2395 for (int i = 0; i < 1020; ++i) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 HandleScope scope(isolate); 2435 HandleScope scope(isolate);
2284 2436
2285 Assembler assm(isolate, NULL, 0); 2437 Assembler assm(isolate, NULL, 0);
2286 __ mov(r0, Operand(isolate->factory()->infinity_value())); 2438 __ mov(r0, Operand(isolate->factory()->infinity_value()));
2287 __ BlockConstPoolFor(1019); 2439 __ BlockConstPoolFor(1019);
2288 for (int i = 0; i < 1019; ++i) __ nop(); 2440 for (int i = 0; i < 1019; ++i) __ nop();
2289 __ vldr(d0, MemOperand(r0, 0)); 2441 __ vldr(d0, MemOperand(r0, 0));
2290 } 2442 }
2291 2443
2292 #undef __ 2444 #undef __
OLDNEW
« no previous file with comments | « src/compiler/arm/instruction-selector-arm.cc ('k') | test/cctest/test-disasm-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698