Skip to content

Commit b2d73e4

Browse files
committed
Simplify mint comparison code on ARM.
[email protected] Review URL: https://codereview.chromium.org//766313002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42053 260f80e4-7a28-3924-810f-c04153c831b5
1 parent 1bace14 commit b2d73e4

File tree

2 files changed

+32
-39
lines changed

2 files changed

+32
-39
lines changed

runtime/vm/intermediate_language_arm.cc

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -570,50 +570,46 @@ static Condition EmitUnboxedMintEqualityOp(FlowGraphCompiler* compiler,
570570

571571
static Condition EmitUnboxedMintComparisonOp(FlowGraphCompiler* compiler,
572572
LocationSummary* locs,
573-
Token::Kind kind) {
573+
Token::Kind kind,
574+
BranchLabels labels) {
574575
PairLocation* left_pair = locs->in(0).AsPairLocation();
575576
Register left_lo = left_pair->At(0).reg();
576577
Register left_hi = left_pair->At(1).reg();
577578
PairLocation* right_pair = locs->in(1).AsPairLocation();
578579
Register right_lo = right_pair->At(0).reg();
579580
Register right_hi = right_pair->At(1).reg();
580581

581-
Register out = locs->temp(0).reg();
582-
583-
// 64-bit comparison
584-
Condition hi_true_cond, hi_false_cond, lo_false_cond;
582+
// 64-bit comparison.
583+
Condition hi_cond, lo_cond;
585584
switch (kind) {
586585
case Token::kLT:
587-
case Token::kLTE:
588-
hi_true_cond = LT;
589-
hi_false_cond = GT;
590-
lo_false_cond = (kind == Token::kLT) ? CS : HI;
586+
hi_cond = LT;
587+
lo_cond = CC;
591588
break;
592589
case Token::kGT:
590+
hi_cond = GT;
591+
lo_cond = HI;
592+
break;
593+
case Token::kLTE:
594+
hi_cond = LT;
595+
lo_cond = LS;
596+
break;
593597
case Token::kGTE:
594-
hi_true_cond = GT;
595-
hi_false_cond = LT;
596-
lo_false_cond = (kind == Token::kGT) ? LS : CC;
598+
hi_cond = GT;
599+
lo_cond = CS;
597600
break;
598601
default:
599602
UNREACHABLE();
600-
hi_true_cond = hi_false_cond = lo_false_cond = VS;
603+
hi_cond = lo_cond = VS;
601604
}
602-
603-
Label done;
604605
// Compare upper halves first.
605606
__ cmp(left_hi, Operand(right_hi));
606-
__ LoadImmediate(out, 0, hi_false_cond);
607-
__ LoadImmediate(out, 1, hi_true_cond);
608-
// If higher words aren't equal, skip comparing lower words.
609-
__ b(&done, NE);
607+
__ b(labels.true_label, hi_cond);
608+
__ b(labels.false_label, FlipCondition(hi_cond));
610609

610+
// If higher words are equal, compare lower words.
611611
__ cmp(left_lo, Operand(right_lo));
612-
__ LoadImmediate(out, 1);
613-
__ LoadImmediate(out, 0, lo_false_cond);
614-
__ Bind(&done);
615-
616-
return NegateCondition(lo_false_cond);
612+
return lo_cond;
617613
}
618614

619615

@@ -822,14 +818,13 @@ LocationSummary* RelationalOpInstr::MakeLocationSummary(Isolate* isolate,
822818
const intptr_t kNumInputs = 2;
823819
const intptr_t kNumTemps = 0;
824820
if (operation_cid() == kMintCid) {
825-
const intptr_t kNumTemps = 1;
821+
const intptr_t kNumTemps = 0;
826822
LocationSummary* locs = new(isolate) LocationSummary(
827823
isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
828824
locs->set_in(0, Location::Pair(Location::RequiresRegister(),
829825
Location::RequiresRegister()));
830826
locs->set_in(1, Location::Pair(Location::RequiresRegister(),
831827
Location::RequiresRegister()));
832-
locs->set_temp(0, Location::RequiresRegister()); // TODO(regis): Improve.
833828
locs->set_out(0, Location::RequiresRegister());
834829
return locs;
835830
}
@@ -860,7 +855,7 @@ Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
860855
if (operation_cid() == kSmiCid) {
861856
return EmitSmiComparisonOp(compiler, locs(), kind());
862857
} else if (operation_cid() == kMintCid) {
863-
return EmitUnboxedMintComparisonOp(compiler, locs(), kind());
858+
return EmitUnboxedMintComparisonOp(compiler, locs(), kind(), labels);
864859
} else {
865860
ASSERT(operation_cid() == kDoubleCid);
866861
return EmitDoubleComparisonOp(compiler, locs(), kind());
@@ -869,19 +864,23 @@ Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
869864

870865

871866
void RelationalOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
872-
// The ARM code does not use true- and false-labels here.
873-
BranchLabels labels = { NULL, NULL, NULL };
867+
Label is_true, is_false;
868+
BranchLabels labels = { &is_true, &is_false, &is_false };
874869
Condition true_condition = EmitComparisonCode(compiler, labels);
875870

876871
const Register result = locs()->out(0).reg();
877872
if (operation_cid() == kSmiCid) {
878873
__ LoadObject(result, Bool::True(), true_condition);
879874
__ LoadObject(result, Bool::False(), NegateCondition(true_condition));
880875
} else if (operation_cid() == kMintCid) {
881-
const Register cr = locs()->temp(0).reg();
876+
EmitBranchOnCondition(compiler, true_condition, labels);
877+
Label done;
878+
__ Bind(&is_false);
879+
__ LoadObject(result, Bool::False());
880+
__ b(&done);
881+
__ Bind(&is_true);
882882
__ LoadObject(result, Bool::True());
883-
__ CompareImmediate(cr, 1);
884-
__ LoadObject(result, Bool::False(), NE);
883+
__ Bind(&done);
885884
} else {
886885
ASSERT(operation_cid() == kDoubleCid);
887886
Label done;
@@ -900,13 +899,8 @@ void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler,
900899
BranchLabels labels = compiler->CreateBranchLabels(branch);
901900
Condition true_condition = EmitComparisonCode(compiler, labels);
902901

903-
if (operation_cid() == kSmiCid) {
902+
if ((operation_cid() == kSmiCid) || (operation_cid() == kMintCid)) {
904903
EmitBranchOnCondition(compiler, true_condition, labels);
905-
} else if (operation_cid() == kMintCid) {
906-
const Register result = locs()->temp(0).reg(); // TODO(regis): Improve.
907-
__ CompareImmediate(result, 1);
908-
__ b(labels.true_label, EQ);
909-
__ b(labels.false_label, NE);
910904
} else if (operation_cid() == kDoubleCid) {
911905
Label* nan_result = (true_condition == NE) ?
912906
labels.true_label : labels.false_label;

runtime/vm/intermediate_language_ia32.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ static Condition EmitUnboxedMintComparisonOp(FlowGraphCompiler* compiler,
523523
break;
524524
}
525525
ASSERT(hi_cond != OVERFLOW && lo_cond != OVERFLOW);
526-
Label is_true, is_false;
527526
// Compare upper halves first.
528527
__ cmpl(left2, right2);
529528
__ j(hi_cond, labels.true_label);

0 commit comments

Comments
 (0)