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

Issue 12091100: Use SAR for positive divident by a power-of two constant divisor. (Closed)

Created:
7 years, 10 months ago by srdjan
Modified:
7 years, 10 months ago
Reviewers:
Florian Schneider
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Use SAR for divident by a power-of two constant divisor. Committed: https://code.google.com/p/dart/source/detail?r=18075

Patch Set 1 #

Patch Set 2 : #

Total comments: 6

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Total comments: 13

Patch Set 6 : #

Patch Set 7 : #

Patch Set 8 : #

Patch Set 9 : #

Patch Set 10 : #

Patch Set 11 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+212 lines, -16 lines) Patch
M runtime/vm/flow_graph_optimizer.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/intermediate_language.h View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 2 3 4 5 1 chunk +10 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 2 3 4 5 3 chunks +46 lines, -8 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 2 3 4 5 6 7 4 chunks +47 lines, -7 lines 0 comments Download
A tests/language/div_with_power_of_two_test.dart View 1 2 3 4 5 1 chunk +103 lines, -0 lines 0 comments Download
M tests/language/language_dart2js.status View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
srdjan
7 years, 10 months ago (2013-02-01 00:12:14 UTC) #1
Florian Schneider
https://codereview.chromium.org/12091100/diff/4001/runtime/vm/intermediate_language_ia32.cc File runtime/vm/intermediate_language_ia32.cc (right): https://codereview.chromium.org/12091100/diff/4001/runtime/vm/intermediate_language_ia32.cc#newcode2035 runtime/vm/intermediate_language_ia32.cc:2035: __ cmpl(left, Immediate(0)); For checking x < 0, this ...
7 years, 10 months ago (2013-02-01 11:48:33 UTC) #2
srdjan
Improved code, handle negative arguments. https://codereview.chromium.org/12091100/diff/4001/runtime/vm/intermediate_language_ia32.cc File runtime/vm/intermediate_language_ia32.cc (right): https://codereview.chromium.org/12091100/diff/4001/runtime/vm/intermediate_language_ia32.cc#newcode2037 runtime/vm/intermediate_language_ia32.cc:2037: // Positive division by ...
7 years, 10 months ago (2013-02-01 22:57:54 UTC) #3
Florian Schneider
LGTM! https://codereview.chromium.org/12091100/diff/4001/runtime/vm/intermediate_language_ia32.cc File runtime/vm/intermediate_language_ia32.cc (right): https://codereview.chromium.org/12091100/diff/4001/runtime/vm/intermediate_language_ia32.cc#newcode2041 runtime/vm/intermediate_language_ia32.cc:2041: __ Bind(&use_div); On 2013/02/01 11:48:33, Florian Schneider wrote: ...
7 years, 10 months ago (2013-02-04 13:04:02 UTC) #4
srdjan
7 years, 10 months ago (2013-02-04 19:02:33 UTC) #5
Thanks!

https://codereview.chromium.org/12091100/diff/17001/runtime/vm/intermediate_l...
File runtime/vm/intermediate_language_ia32.cc (right):

https://codereview.chromium.org/12091100/diff/17001/runtime/vm/intermediate_l...
runtime/vm/intermediate_language_ia32.cc:2051: if (shift_count > 1) {
On 2013/02/04 13:04:03, Florian Schneider wrote:
> Redundant if-statment? shift_count will only be 1 if the rhs value is 1 or -1
> here. Those cases are already handled above.

Removed

https://codereview.chromium.org/12091100/diff/17001/runtime/vm/intermediate_l...
runtime/vm/intermediate_language_ia32.cc:2055: if (shift_count > 0) {
On 2013/02/04 13:04:03, Florian Schneider wrote:
> shift_count will always be > 0 here because kSmiTagSize == 1.
> 
> Maybe remove this if-statement and just ASSERT(kSmiTagSize >= 1).

Done.

https://codereview.chromium.org/12091100/diff/17001/tests/language/div_with_p...
File tests/language/div_with_power_of_two_test.dart (right):

https://codereview.chromium.org/12091100/diff/17001/tests/language/div_with_p...
tests/language/div_with_power_of_two_test.dart:11: TestValue(func, arg) :
function = func, argument = arg, result = func(arg) {}
On 2013/02/04 13:04:03, Florian Schneider wrote:
> How do you prevent func from already being optimized at this point? If
> optimization_threshold changes, or just adding more test cases may break this
> test.
> 
> Unfortunately I don't know a good way of generating tests like this in Dart.
> Dynamic code generation would help greatly here.
> 
> So I think the only reliable way is to list all expected results as constants.

Added expected values as well.

https://codereview.chromium.org/12091100/diff/17001/tests/language/div_with_p...
tests/language/div_with_power_of_two_test.dart:16: divByNeg4(a) => a ~/ - 4;
On 2013/02/04 13:04:03, Florian Schneider wrote:
> Remove extra space after -
> 
> /s/- 4/-4/

Done.

https://codereview.chromium.org/12091100/diff/17001/tests/language/div_with_p...
tests/language/div_with_power_of_two_test.dart:19: 
On 2013/02/04 13:04:03, Florian Schneider wrote:
> Please add tests for the special cases:
> 
> a ~/ 0
> a ~/ 1
> a ~/ -1
> a ~/ 2
> a ~/ -2

Done.

https://codereview.chromium.org/12091100/diff/17001/tests/language/div_with_p...
tests/language/div_with_power_of_two_test.dart:21: divByNeg4_(a) => a ~/ - 4;
On 2013/02/04 13:04:03, Florian Schneider wrote:
> /s/- 4/-4/

Done.

Powered by Google App Engine
This is Rietveld 408576698