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

Issue 14057004: Convert diamond shaped control flow into a single conditional instruction. (Closed)

Created:
7 years, 8 months ago by Vyacheslav Egorov (Google)
Modified:
7 years, 8 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Convert diamond shaped control flow into a single conditional instruction. Adds a IfConverter pass that right now recognizes two simple patterns cond ? 0 : 2^n and cond ? x : x+-1 that can be generated without branches on ia32 and x64 using setcc instruction. R=fschneider@google.com Committed: https://code.google.com/p/dart/source/detail?r=21207

Patch Set 1 #

Total comments: 12

Patch Set 2 : address Florian's comments #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+724 lines, -26 lines) Patch
M runtime/vm/assembler_ia32.h View 2 chunks +3 lines, -0 lines 0 comments Download
M runtime/vm/assembler_ia32.cc View 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/vm/assembler_ia32_test.cc View 1 chunk +15 lines, -0 lines 0 comments Download
M runtime/vm/assembler_x64.h View 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/assembler_x64.cc View 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/vm/assembler_x64_test.cc View 1 chunk +15 lines, -0 lines 0 comments Download
M runtime/vm/compiler.cc View 1 chunk +3 lines, -0 lines 0 comments Download
M runtime/vm/disassembler_ia32.cc View 3 chunks +9 lines, -4 lines 0 comments Download
M runtime/vm/flow_graph.h View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/flow_graph_optimizer.h View 1 chunk +9 lines, -0 lines 0 comments Download
M runtime/vm/flow_graph_optimizer.cc View 1 2 chunks +162 lines, -0 lines 2 comments Download
M runtime/vm/flow_graph_type_propagator.cc View 1 chunk +6 lines, -0 lines 0 comments Download
M runtime/vm/il_printer.cc View 1 chunk +10 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language.h View 1 4 chunks +63 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language_arm.cc View 1 chunk +24 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 1 chunk +121 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language_mips.cc View 1 chunk +24 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 2 chunks +141 lines, -20 lines 0 comments Download
A tests/language/if_conversion_vm_test.dart View 1 1 chunk +92 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Vyacheslav Egorov (Google)
7 years, 8 months ago (2013-04-10 13:22:33 UTC) #1
Florian Schneider
LGTM. Please ensure test coverage for both cases: power-of-two and increment by 1. https://codereview.chromium.org/14057004/diff/1/runtime/vm/flow_graph_optimizer.cc File ...
7 years, 8 months ago (2013-04-10 13:59:50 UTC) #2
Vyacheslav Egorov (Google)
Thanks you for the review. Comments addressed. Test added. Landing. https://codereview.chromium.org/14057004/diff/1/runtime/vm/flow_graph_optimizer.cc File runtime/vm/flow_graph_optimizer.cc (right): https://codereview.chromium.org/14057004/diff/1/runtime/vm/flow_graph_optimizer.cc#newcode3938 ...
7 years, 8 months ago (2013-04-10 14:51:32 UTC) #3
Vyacheslav Egorov (Google)
Committed patchset #2 manually as r21207 (presubmit successful).
7 years, 8 months ago (2013-04-10 15:10:15 UTC) #4
srdjan
dbc https://codereview.chromium.org/14057004/diff/7001/runtime/vm/flow_graph_optimizer.cc File runtime/vm/flow_graph_optimizer.cc (right): https://codereview.chromium.org/14057004/diff/7001/runtime/vm/flow_graph_optimizer.cc#newcode3955 runtime/vm/flow_graph_optimizer.cc:3955: bool result = (left.raw() == right.raw()); Since equality ...
7 years, 8 months ago (2013-04-10 21:47:30 UTC) #5
Vyacheslav Egorov (Google)
7 years, 8 months ago (2013-04-10 21:51:28 UTC) #6
Message was sent while issue was closed.
https://codereview.chromium.org/14057004/diff/7001/runtime/vm/flow_graph_opti...
File runtime/vm/flow_graph_optimizer.cc (right):

https://codereview.chromium.org/14057004/diff/7001/runtime/vm/flow_graph_opti...
runtime/vm/flow_graph_optimizer.cc:3955: bool result = (left.raw() ==
right.raw());
On 2013/04/10 21:47:30, srdjan wrote:
> Since equality can be overridden, I do not think that you can compute result
> unless the constants are of certain types (two smi's, etc). The code in
> IfThenElseInstr::Supports limits the possible combination, but if that changes
> this code could become invalid. Maybe you want to add asserts for allowed
types?

Agreed, this is fragile. 

The plan is to remove this code and encapsulate all codegeneration and constant
folding of comparisons in the ComparisonInstr which will actually stop being an
actual instruction all together. All current uses of comparisons will be
generated as:

v <- IfThenElse(Comparison(v1, v2) ? true : false)

instead of current

v <- Comparison(v1, v2)

Powered by Google App Engine
This is Rietveld 408576698