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

Side by Side Diff: src/compiler/arm64/instruction-selector-arm64.cc

Issue 2475433005: [turbofan] Refactor the compare-zero folding in instruction selector. (Closed)
Patch Set: Make mips64 happy Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/instruction-selector-impl.h" 5 #include "src/compiler/instruction-selector-impl.h"
6 #include "src/compiler/node-matchers.h" 6 #include "src/compiler/node-matchers.h"
7 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 g.UseImmediate(m.left().node()), cont); 2346 g.UseImmediate(m.left().node()), cont);
2347 } else { 2347 } else {
2348 VisitCompare(selector, kArm64Float64Cmp, g.UseRegister(m.left().node()), 2348 VisitCompare(selector, kArm64Float64Cmp, g.UseRegister(m.left().node()),
2349 g.UseRegister(m.right().node()), cont); 2349 g.UseRegister(m.right().node()), cont);
2350 } 2350 }
2351 } 2351 }
2352 2352
2353 void VisitWordCompareZero(InstructionSelector* selector, Node* user, 2353 void VisitWordCompareZero(InstructionSelector* selector, Node* user,
2354 Node* value, FlagsContinuation* cont) { 2354 Node* value, FlagsContinuation* cont) {
2355 Arm64OperandGenerator g(selector); 2355 Arm64OperandGenerator g(selector);
2356 while (selector->CanCover(user, value)) { 2356 // Try to combine with comparisons against 0 by simply inverting the branch.
2357 while (value->opcode() == IrOpcode::kWord32Equal &&
2358 selector->CanCover(user, value)) {
2359 Int32BinopMatcher m(value);
2360 if (!m.right().Is(0)) break;
2361
2362 user = value;
2363 value = m.left().node();
2364 cont->Negate();
2365 }
2366
2367 if (selector->CanCover(user, value)) {
2357 switch (value->opcode()) { 2368 switch (value->opcode()) {
2358 case IrOpcode::kWord32Equal: { 2369 case IrOpcode::kWord32Equal:
2359 // Combine with comparisons against 0 by simply inverting the
2360 // continuation.
2361 Int32BinopMatcher m(value);
2362 if (m.right().Is(0)) {
2363 user = value;
2364 value = m.left().node();
2365 cont->Negate();
2366 continue;
2367 }
2368 cont->OverwriteAndNegateIfEqual(kEqual); 2370 cont->OverwriteAndNegateIfEqual(kEqual);
2369 return VisitWord32Compare(selector, value, cont); 2371 return VisitWord32Compare(selector, value, cont);
2370 }
2371 case IrOpcode::kInt32LessThan: 2372 case IrOpcode::kInt32LessThan:
2372 cont->OverwriteAndNegateIfEqual(kSignedLessThan); 2373 cont->OverwriteAndNegateIfEqual(kSignedLessThan);
2373 return VisitWord32Compare(selector, value, cont); 2374 return VisitWord32Compare(selector, value, cont);
2374 case IrOpcode::kInt32LessThanOrEqual: 2375 case IrOpcode::kInt32LessThanOrEqual:
2375 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); 2376 cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual);
2376 return VisitWord32Compare(selector, value, cont); 2377 return VisitWord32Compare(selector, value, cont);
2377 case IrOpcode::kUint32LessThan: 2378 case IrOpcode::kUint32LessThan:
2378 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); 2379 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan);
2379 return VisitWord32Compare(selector, value, cont); 2380 return VisitWord32Compare(selector, value, cont);
2380 case IrOpcode::kUint32LessThanOrEqual: 2381 case IrOpcode::kUint32LessThanOrEqual:
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 case IrOpcode::kWord64And: 2499 case IrOpcode::kWord64And:
2499 if (TryEmitTestAndBranch<Uint64BinopMatcher, kArm64TestAndBranch>( 2500 if (TryEmitTestAndBranch<Uint64BinopMatcher, kArm64TestAndBranch>(
2500 selector, value, cont)) { 2501 selector, value, cont)) {
2501 return; 2502 return;
2502 } 2503 }
2503 return VisitWordCompare(selector, value, kArm64Tst, cont, true, 2504 return VisitWordCompare(selector, value, kArm64Tst, cont, true,
2504 kLogical64Imm); 2505 kLogical64Imm);
2505 default: 2506 default:
2506 break; 2507 break;
2507 } 2508 }
2508 break;
2509 } 2509 }
2510 2510
2511 // Branch could not be combined with a compare, compare against 0 and branch. 2511 // Branch could not be combined with a compare, compare against 0 and branch.
2512 if (cont->IsBranch()) { 2512 if (cont->IsBranch()) {
2513 selector->Emit(cont->Encode(kArm64CompareAndBranch32), g.NoOutput(), 2513 selector->Emit(cont->Encode(kArm64CompareAndBranch32), g.NoOutput(),
2514 g.UseRegister(value), g.Label(cont->true_block()), 2514 g.UseRegister(value), g.Label(cont->true_block()),
2515 g.Label(cont->false_block())); 2515 g.Label(cont->false_block()));
2516 } else { 2516 } else {
2517 DCHECK(cont->IsDeoptimize()); 2517 DCHECK(cont->IsDeoptimize());
2518 selector->EmitDeoptimize(cont->Encode(kArm64Tst32), g.NoOutput(), 2518 selector->EmitDeoptimize(cont->Encode(kArm64Tst32), g.NoOutput(),
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 // static 2905 // static
2906 MachineOperatorBuilder::AlignmentRequirements 2906 MachineOperatorBuilder::AlignmentRequirements
2907 InstructionSelector::AlignmentRequirements() { 2907 InstructionSelector::AlignmentRequirements() {
2908 return MachineOperatorBuilder::AlignmentRequirements:: 2908 return MachineOperatorBuilder::AlignmentRequirements::
2909 FullUnalignedAccessSupport(); 2909 FullUnalignedAccessSupport();
2910 } 2910 }
2911 2911
2912 } // namespace compiler 2912 } // namespace compiler
2913 } // namespace internal 2913 } // namespace internal
2914 } // namespace v8 2914 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm/instruction-selector-arm.cc ('k') | src/compiler/ia32/instruction-selector-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698