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

Side by Side Diff: runtime/vm/intermediate_language_arm64.cc

Issue 2463593002: VM: Enable branch merging of isnan, isinf. (Closed)
Patch Set: addressed comments 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
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_dbc.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 (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 case EQ: return NE; 116 case EQ: return NE;
117 case NE: return EQ; 117 case NE: return EQ;
118 case LT: return GE; 118 case LT: return GE;
119 case LE: return GT; 119 case LE: return GT;
120 case GT: return LE; 120 case GT: return LE;
121 case GE: return LT; 121 case GE: return LT;
122 case CC: return CS; 122 case CC: return CS;
123 case LS: return HI; 123 case LS: return HI;
124 case HI: return LS; 124 case HI: return LS;
125 case CS: return CC; 125 case CS: return CC;
126 case VS: return VC;
127 case VC: return VS;
126 default: 128 default:
127 UNREACHABLE(); 129 UNREACHABLE();
128 return EQ; 130 return EQ;
129 } 131 }
130 } 132 }
131 133
132 134
133 // Detect pattern when one value is zero and another is a power of 2. 135 // Detect pattern when one value is zero and another is a power of 2.
134 static bool IsPowerOfTwoKind(intptr_t v1, intptr_t v2) { 136 static bool IsPowerOfTwoKind(intptr_t v1, intptr_t v2) {
135 return (Utils::IsPowerOfTwo(v1) && (v2 == 0)) || 137 return (Utils::IsPowerOfTwo(v1) && (v2 == 0)) ||
(...skipping 3342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 case Token::kMUL: __ fmuld(result, left, right); break; 3480 case Token::kMUL: __ fmuld(result, left, right); break;
3479 case Token::kDIV: __ fdivd(result, left, right); break; 3481 case Token::kDIV: __ fdivd(result, left, right); break;
3480 default: UNREACHABLE(); 3482 default: UNREACHABLE();
3481 } 3483 }
3482 } 3484 }
3483 3485
3484 3486
3485 LocationSummary* DoubleTestOpInstr::MakeLocationSummary(Zone* zone, 3487 LocationSummary* DoubleTestOpInstr::MakeLocationSummary(Zone* zone,
3486 bool opt) const { 3488 bool opt) const {
3487 const intptr_t kNumInputs = 1; 3489 const intptr_t kNumInputs = 1;
3488 const intptr_t kNumTemps = 0; 3490 const intptr_t kNumTemps =
3491 op_kind() == MethodRecognizer::kDouble_getIsInfinite ? 1 : 0;
3489 LocationSummary* summary = new(zone) LocationSummary( 3492 LocationSummary* summary = new(zone) LocationSummary(
3490 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 3493 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
3491 summary->set_in(0, Location::RequiresFpuRegister()); 3494 summary->set_in(0, Location::RequiresFpuRegister());
3495 if (op_kind() == MethodRecognizer::kDouble_getIsInfinite) {
3496 summary->set_temp(0, Location::RequiresRegister());
3497 }
3492 summary->set_out(0, Location::RequiresRegister()); 3498 summary->set_out(0, Location::RequiresRegister());
3493 return summary; 3499 return summary;
3494 } 3500 }
3495 3501
3496 3502
3497 void DoubleTestOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3503 Condition DoubleTestOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
3504 BranchLabels labels) {
3498 ASSERT(compiler->is_optimizing()); 3505 ASSERT(compiler->is_optimizing());
3499 const VRegister value = locs()->in(0).fpu_reg(); 3506 const VRegister value = locs()->in(0).fpu_reg();
3500 const Register result = locs()->out(0).reg(); 3507 const bool is_negated = kind() != Token::kEQ;
3501 if (op_kind() == MethodRecognizer::kDouble_getIsNaN) { 3508 if (op_kind() == MethodRecognizer::kDouble_getIsNaN) {
3502 __ fcmpd(value, value); 3509 __ fcmpd(value, value);
3503 __ LoadObject(result, Bool::False()); 3510 return is_negated ? VC : VS;
3504 __ LoadObject(TMP, Bool::True());
3505 __ csel(result, TMP, result, VS);
3506 } else { 3511 } else {
3507 ASSERT(op_kind() == MethodRecognizer::kDouble_getIsInfinite); 3512 ASSERT(op_kind() == MethodRecognizer::kDouble_getIsInfinite);
3508 __ vmovrd(result, value, 0); 3513 const Register temp = locs()->temp(0).reg();
3514 __ vmovrd(temp, value, 0);
3509 // Mask off the sign. 3515 // Mask off the sign.
3510 __ AndImmediate(result, result, 0x7FFFFFFFFFFFFFFFLL); 3516 __ AndImmediate(temp, temp, 0x7FFFFFFFFFFFFFFFLL);
3511 // Compare with +infinity. 3517 // Compare with +infinity.
3512 __ CompareImmediate(result, 0x7FF0000000000000LL); 3518 __ CompareImmediate(temp, 0x7FF0000000000000LL);
3513 __ LoadObject(result, Bool::False()); 3519 return is_negated ? NE : EQ;
3514 __ LoadObject(TMP, Bool::True());
3515 __ csel(result, TMP, result, EQ);
3516 } 3520 }
3517 } 3521 }
3518 3522
3523
3524 void DoubleTestOpInstr::EmitBranchCode(FlowGraphCompiler* compiler,
3525 BranchInstr* branch) {
3526 ASSERT(compiler->is_optimizing());
3527 BranchLabels labels = compiler->CreateBranchLabels(branch);
3528 Condition true_condition = EmitComparisonCode(compiler, labels);
3529 EmitBranchOnCondition(compiler, true_condition, labels);
3530 }
3531
3532
3533 void DoubleTestOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3534 ASSERT(compiler->is_optimizing());
3535 Label is_true, is_false;
3536 BranchLabels labels = { &is_true, &is_false, &is_false };
3537 Condition true_condition = EmitComparisonCode(compiler, labels);
3538 const Register result = locs()->out(0).reg();
3539 if (op_kind() == MethodRecognizer::kDouble_getIsNaN) {
3540 __ LoadObject(result, Bool::False());
3541 __ LoadObject(TMP, Bool::True());
3542 __ csel(result, TMP, result, true_condition);
3543 } else {
3544 __ LoadObject(result, Bool::False());
3545 __ LoadObject(TMP, Bool::True());
3546 __ csel(result, TMP, result, true_condition);
3547 }
3548 }
3549
3519 3550
3520 LocationSummary* BinaryFloat32x4OpInstr::MakeLocationSummary(Zone* zone, 3551 LocationSummary* BinaryFloat32x4OpInstr::MakeLocationSummary(Zone* zone,
3521 bool opt) const { 3552 bool opt) const {
3522 const intptr_t kNumInputs = 2; 3553 const intptr_t kNumInputs = 2;
3523 const intptr_t kNumTemps = 0; 3554 const intptr_t kNumTemps = 0;
3524 LocationSummary* summary = new(zone) LocationSummary( 3555 LocationSummary* summary = new(zone) LocationSummary(
3525 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 3556 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
3526 summary->set_in(0, Location::RequiresFpuRegister()); 3557 summary->set_in(0, Location::RequiresFpuRegister());
3527 summary->set_in(1, Location::RequiresFpuRegister()); 3558 summary->set_in(1, Location::RequiresFpuRegister());
3528 summary->set_out(0, Location::RequiresFpuRegister()); 3559 summary->set_out(0, Location::RequiresFpuRegister());
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after
5815 1, 5846 1,
5816 locs()); 5847 locs());
5817 __ Drop(1); 5848 __ Drop(1);
5818 __ Pop(result); 5849 __ Pop(result);
5819 } 5850 }
5820 5851
5821 5852
5822 } // namespace dart 5853 } // namespace dart
5823 5854
5824 #endif // defined TARGET_ARCH_ARM64 5855 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_dbc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698