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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 288853003: Allow div and cmp to work in uint32 mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | no next file » | 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 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 // Check for (kMinInt / -1). 1360 // Check for (kMinInt / -1).
1361 if (divisor == -1 && instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { 1361 if (divisor == -1 && instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1362 __ cmp(dividend, kMinInt); 1362 __ cmp(dividend, kMinInt);
1363 DeoptimizeIf(zero, instr->environment()); 1363 DeoptimizeIf(zero, instr->environment());
1364 } 1364 }
1365 test_value = - divisor - 1; 1365 test_value = - divisor - 1;
1366 power = WhichPowerOf2(-divisor); 1366 power = WhichPowerOf2(-divisor);
1367 } 1367 }
1368 1368
1369 if (test_value != 0) { 1369 if (test_value != 0) {
1370 if (instr->hydrogen()->CheckFlag( 1370 if (instr->hydrogen()->CheckFlag(HInstruction::kUint32)) {
1371 __ sar(dividend, power);
1372 } else if (instr->hydrogen()->CheckFlag(
1371 HInstruction::kAllUsesTruncatingToInt32)) { 1373 HInstruction::kAllUsesTruncatingToInt32)) {
1372 Label done, negative; 1374 Label done, negative;
1373 __ cmp(dividend, 0); 1375 __ cmp(dividend, 0);
1374 __ j(less, &negative, Label::kNear); 1376 __ j(less, &negative, Label::kNear);
1375 __ sar(dividend, power); 1377 __ sar(dividend, power);
1376 __ jmp(&done, Label::kNear); 1378 __ jmp(&done, Label::kNear);
1377 1379
1378 __ bind(&negative); 1380 __ bind(&negative);
1379 __ neg(dividend); 1381 __ neg(dividend);
1380 __ sar(dividend, power); 1382 __ sar(dividend, power);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 // Check for (kMinInt / -1). 1424 // Check for (kMinInt / -1).
1423 if (instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)) { 1425 if (instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)) {
1424 Label left_not_min_int; 1426 Label left_not_min_int;
1425 __ cmp(left_reg, kMinInt); 1427 __ cmp(left_reg, kMinInt);
1426 __ j(not_zero, &left_not_min_int, Label::kNear); 1428 __ j(not_zero, &left_not_min_int, Label::kNear);
1427 __ cmp(right_reg, -1); 1429 __ cmp(right_reg, -1);
1428 DeoptimizeIf(zero, instr->environment()); 1430 DeoptimizeIf(zero, instr->environment());
1429 __ bind(&left_not_min_int); 1431 __ bind(&left_not_min_int);
1430 } 1432 }
1431 1433
1432 // Sign extend to edx. 1434 if (instr->hydrogen()->CheckFlag(HInstruction::kUint32)) {
1433 __ cdq(); 1435 // Zero out edx (don't use cdq, this is unsigned).
1434 __ idiv(right_reg); 1436 __ xor_(edx, edx);
1437 __ div(right_reg);
1438 } else {
1439 // Sign extend to edx.
1440 __ cdq();
1441 __ idiv(right_reg);
1442 }
1435 1443
1436 if (instr->is_flooring()) { 1444 if (instr->is_flooring()) {
1437 Label done; 1445 Label done;
1438 __ test(edx, edx); 1446 __ test(edx, edx);
1439 __ j(zero, &done, Label::kNear); 1447 __ j(zero, &done, Label::kNear);
1440 __ xor_(edx, right_reg); 1448 __ xor_(edx, right_reg);
1441 __ sar(edx, 31); 1449 __ sar(edx, 31);
1442 __ add(eax, edx); 1450 __ add(eax, edx);
1443 __ bind(&done); 1451 __ bind(&done);
1444 } else if (!instr->hydrogen()->CheckFlag( 1452 } else if (!instr->hydrogen()->CheckFlag(
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 } 2315 }
2308 return cond; 2316 return cond;
2309 } 2317 }
2310 2318
2311 2319
2312 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) { 2320 void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
2313 LOperand* left = instr->left(); 2321 LOperand* left = instr->left();
2314 LOperand* right = instr->right(); 2322 LOperand* right = instr->right();
2315 int false_block = chunk_->LookupDestination(instr->false_block_id()); 2323 int false_block = chunk_->LookupDestination(instr->false_block_id());
2316 int true_block = chunk_->LookupDestination(instr->true_block_id()); 2324 int true_block = chunk_->LookupDestination(instr->true_block_id());
2317 Condition cc = TokenToCondition(instr->op(), instr->is_double()); 2325 bool is_unsigned =
2326 instr->is_double() || instr->hydrogen()->CheckFlag(HInstruction::kUint32);
2327 Condition cc = TokenToCondition(instr->op(), is_unsigned);
2318 2328
2319 if (left->IsConstantOperand() && right->IsConstantOperand()) { 2329 if (left->IsConstantOperand() && right->IsConstantOperand()) {
2320 // We can statically evaluate the comparison. 2330 // We can statically evaluate the comparison.
2321 double left_val = ToDouble(LConstantOperand::cast(left)); 2331 double left_val = ToDouble(LConstantOperand::cast(left));
2322 double right_val = ToDouble(LConstantOperand::cast(right)); 2332 double right_val = ToDouble(LConstantOperand::cast(right));
2323 int next_block = 2333 int next_block =
2324 EvalComparison(instr->op(), left_val, right_val) ? true_block 2334 EvalComparison(instr->op(), left_val, right_val) ? true_block
2325 : false_block; 2335 : false_block;
2326 EmitGoto(next_block); 2336 EmitGoto(next_block);
2327 } else { 2337 } else {
(...skipping 4196 matching lines...) Expand 10 before | Expand all | Expand 10 after
6524 FixedArray::kHeaderSize - kPointerSize)); 6534 FixedArray::kHeaderSize - kPointerSize));
6525 __ bind(&done); 6535 __ bind(&done);
6526 } 6536 }
6527 6537
6528 6538
6529 #undef __ 6539 #undef __
6530 6540
6531 } } // namespace v8::internal 6541 } } // namespace v8::internal
6532 6542
6533 #endif // V8_TARGET_ARCH_IA32 6543 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698