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

Issue 10825071: Use integer division in a certain case. (Closed)

Created:
8 years, 4 months ago by Evan Wallace
Modified:
5 years, 8 months ago
CC:
v8-dev
Visibility:
Public.

Description

Use integer division in a certain case. This optimization triggers when: - Both operands are integers - The result will be truncated to an integer - The dividend is non-negative - The divisor is positive It is done during range analysis because it needs range information for the preconditions and because, if the optimization triggers, the range of the output can also be computed. This optimization also removes the deopt on non-zero remainder since the result is always truncated. BUG=v8:2258 TEST=test/mjsunit/fast-div-int.js

Patch Set 1 #

Total comments: 7

Patch Set 2 : #

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+185 lines, -4 lines) Patch
M AUTHORS View 1 chunk +1 line, -0 lines 0 comments Download
M src/hydrogen-instructions.h View 1 1 chunk +3 lines, -0 lines 0 comments Download
M src/hydrogen-instructions.cc View 1 2 2 chunks +107 lines, -0 lines 0 comments Download
M src/ia32/lithium-codegen-ia32.cc View 1 chunk +4 lines, -2 lines 0 comments Download
M src/x64/lithium-codegen-x64.cc View 1 chunk +4 lines, -2 lines 0 comments Download
A test/mjsunit/fast-div-int.js View 1 chunk +66 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Vyacheslav Egorov (Google)
https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructions.cc File src/hydrogen-instructions.cc (right): https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructions.cc#newcode1151 src/hydrogen-instructions.cc:1151: if (change->value()->IsDiv() && I am a little bit uncomfortable ...
8 years, 4 months ago (2012-07-30 12:01:44 UTC) #1
Evan Wallace
https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructions.cc File src/hydrogen-instructions.cc (right): https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructions.cc#newcode1151 src/hydrogen-instructions.cc:1151: if (change->value()->IsDiv() && These aren't the only conditions that ...
8 years, 4 months ago (2012-07-30 16:43:13 UTC) #2
Vyacheslav Egorov (Google)
https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructions.cc File src/hydrogen-instructions.cc (right): https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructions.cc#newcode1151 src/hydrogen-instructions.cc:1151: if (change->value()->IsDiv() && On 2012/07/30 16:43:13, Evan Wallace wrote: ...
8 years, 4 months ago (2012-07-30 16:59:26 UTC) #3
Evan Wallace
8 years, 4 months ago (2012-07-30 19:35:43 UTC) #4
https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructi...
File src/hydrogen-instructions.cc (right):

https://chromiumcodereview.appspot.com/10825071/diff/1/src/hydrogen-instructi...
src/hydrogen-instructions.cc:1151: if (change->value()->IsDiv() &&
I did not realize normal double to integer representation changes are not
truncating. I will add a check for that flag on "change".

From what I can tell, if the optimization is only applied when the division has
a use count of 1 then marking storing into a typed array as truncating won't
have any effect since "x[0] = 0xFF / (x[0] + 1)" will always generate a simulate
that pushes the division.

What conditions would be necessary to apply this substitution in that case?
Would it be valid to apply this substitution if there are one or more simulate
instructions for which the division is a use but they occur after the change
instruction (instead of before as in your example below)?

Powered by Google App Engine
This is Rietveld 408576698