Commit e6cfe350 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

[turbofan] Fix recognition of Uint32Div in simplified lowering.

TEST=mjsunit/asm
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/701813003

Cr-Commit-Position: refs/heads/master@{#25103}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25103 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1d669345
......@@ -632,7 +632,7 @@ class RepresentationSelector {
if (lower()) DeferReplacement(node, lowering->Int32Div(node));
break;
}
if (CanLowerToUint32Binop(node, use)) {
if (BothInputsAre(node, Type::Unsigned32()) && !CanObserveNaN(use)) {
// => unsigned Uint32Div
VisitUint32Binop(node);
if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
......
......@@ -22,8 +22,24 @@ function Uint32Div(divisor) {
var divisors = [0, 1, 3, 4, 10, 42, 64, 100, 1024, 2147483647, 4294967295];
for (var i in divisors) {
var divisor = divisors[i];
var mod = Uint32Div(divisor);
var div = Uint32Div(divisor);
for (var dividend = 0; dividend < 4294967296; dividend += 3999773) {
assertEquals((dividend / divisor) >>> 0, mod(dividend));
assertEquals((dividend / divisor) >>> 0, div(dividend));
}
}
var div = (function(stdlib, foreign, heap) {
"use asm";
function div(dividend, divisor) {
return (dividend >>> 0) / (divisor >>> 0) | 0;
}
return {div: div};
})(stdlib, foreign, heap).div;
for (var i in divisors) {
var divisor = divisors[i];
for (var dividend = 0; dividend < 4294967296; dividend += 3999773) {
assertEquals((dividend >>> 0) / (divisor >>> 0) | 0,
div(dividend, divisor));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment