|
|
Description[turbofan] Induction variable bound analysis for decrements.
This detects loops with integer decrements.
Drive-by fix: Add lower bounds to lower_bounds
zone vector instead of upper_bounds.
BUG=
Committed: https://crrev.com/6e665b094e7cbb6187fb59e3eb135266fa4c2e96
Cr-Commit-Position: refs/heads/master@{#38772}
Patch Set 1 #Patch Set 2 : Rename constants. #Patch Set 3 : Set lower bounds correctly. #Patch Set 4 : Rename function. #
Total comments: 4
Patch Set 5 : Simplify bound calculation. #Patch Set 6 : Add tests. #Patch Set 7 : Rename testfile. #Patch Set 8 : Rename variable. #Patch Set 9 : Add test for non-constant bound. #
Total comments: 10
Patch Set 10 : Simplify if-else loop #
Depends on Patchset: Messages
Total messages: 40 (31 generated)
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== [turbofan] Induction variable decrement bound analysis. This detects loops with integer decrements. BUG= ========== to ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. BUG= ==========
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. BUG= ========== to ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. Drive-by fix: Add lower bounds to lower_bounds zone vector instead of upper_bounds. BUG= ==========
Description was changed from ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. Drive-by fix: Add lower bounds to lower_bounds zone vector instead of upper_bounds. BUG= ========== to ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. Drive-by fix: Add lower bounds to lower_bounds zone vector instead of upper_bounds. BUG= ==========
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
franzih@chromium.org changed reviewers: + jarin@chromium.org
Hi, I tried the induction variable bound analysis for subtraction. Can you have a look please. Thanks, Franzi
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2260153002/diff/60001/src/compiler/loop-varia... File src/compiler/loop-variable-optimizer.cc (right): https://codereview.chromium.org/2260153002/diff/60001/src/compiler/loop-varia... src/compiler/loop-variable-optimizer.cc:191: var->second->AddLowerBound(constraint->left(), constraint->kind()); Awesome, thanks for the fix! After a bit of thinking, I believe this is a bad bug. For example, the program below does not terminate. function f() { for (var i = 5; i < 10; i++) { if (i < 0) break; if (i === 7) return true; } return false; } f(); f(); %OptimizeFunctionOnNextCall(f); print(f()); https://codereview.chromium.org/2260153002/diff/60001/src/compiler/typer.cc File src/compiler/typer.cc (right): https://codereview.chromium.org/2260153002/diff/60001/src/compiler/typer.cc#n... src/compiler/typer.cc:657: double max = V8_INFINITY; Could not you just say here: double increment_min; double increment_max; if (arithmeticType == InductionVariable::ArithmeticType::kAddition) { increment_min = increment_type->Min(); increment_max = increment_type->Max(); } else { DCHECK(arithmeticType == InductionVariable::ArithmeticType::kSubtraction); increment_min = -increment_type->Max(); increment_max = -increment_type->Min(); } And then just use these below rather than special casing for add/subtract below?
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Thanks for the feedback. I added some test cases. Did I miss any loop variation we should have a test for? Thanks, Franzi https://codereview.chromium.org/2260153002/diff/60001/src/compiler/loop-varia... File src/compiler/loop-variable-optimizer.cc (right): https://codereview.chromium.org/2260153002/diff/60001/src/compiler/loop-varia... src/compiler/loop-variable-optimizer.cc:191: var->second->AddLowerBound(constraint->left(), constraint->kind()); On 2016/08/19 13:08:25, Jarin wrote: > Awesome, thanks for the fix! After a bit of thinking, I believe this is a bad > bug. For example, the program below does not terminate. > > function f() { > for (var i = 5; i < 10; i++) { > if (i < 0) break; > if (i === 7) return true; > } > return false; > } > > f(); > f(); > %OptimizeFunctionOnNextCall(f); > print(f()); Done. https://codereview.chromium.org/2260153002/diff/60001/src/compiler/typer.cc File src/compiler/typer.cc (right): https://codereview.chromium.org/2260153002/diff/60001/src/compiler/typer.cc#n... src/compiler/typer.cc:657: double max = V8_INFINITY; On 2016/08/19 13:08:25, Jarin wrote: > Could not you just say here: > > double increment_min; > double increment_max; > if (arithmeticType == InductionVariable::ArithmeticType::kAddition) { > increment_min = increment_type->Min(); > increment_max = increment_type->Max(); > } else { > DCHECK(arithmeticType == > InductionVariable::ArithmeticType::kSubtraction); > increment_min = -increment_type->Max(); > increment_max = -increment_type->Min(); > } > > And then just use these below rather than special casing for add/subtract below? Done.
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
lgtm once the comments are addressed. https://codereview.chromium.org/2260153002/diff/160001/src/compiler/typer.cc File src/compiler/typer.cc (right): https://codereview.chromium.org/2260153002/diff/160001/src/compiler/typer.cc#... src/compiler/typer.cc:673: arithmetic_type == InductionVariable::ArithmeticType::kSubtraction)) { How about if (increment_min >= 0) { https://codereview.chromium.org/2260153002/diff/160001/src/compiler/typer.cc#... src/compiler/typer.cc:699: // decreasing sequence (add negative values, or subtract positive values) } else if (increment_max <= 0) { https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... File test/mjsunit/induction-variable-turbofan.js (right): https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... test/mjsunit/induction-variable-turbofan.js:26: // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Nit: you can use a shorter copyright. E.g., see test/mjsunit/array-push2.js. https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... test/mjsunit/induction-variable-turbofan.js:31: // the corret upper and lower bounds. Nit: corret -> correct. https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... test/mjsunit/induction-variable-turbofan.js:43: if (i < 0) break; Could we change the i < 0 branches to return false? (They should never trigger.)
The CQ bit was checked by franzih@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2260153002/diff/160001/src/compiler/typer.cc File src/compiler/typer.cc (right): https://codereview.chromium.org/2260153002/diff/160001/src/compiler/typer.cc#... src/compiler/typer.cc:673: arithmetic_type == InductionVariable::ArithmeticType::kSubtraction)) { On 2016/08/22 07:27:20, Jarin wrote: > How about > > if (increment_min >= 0) { Thanks! https://codereview.chromium.org/2260153002/diff/160001/src/compiler/typer.cc#... src/compiler/typer.cc:699: // decreasing sequence (add negative values, or subtract positive values) On 2016/08/22 07:27:19, Jarin wrote: > } else if (increment_max <= 0) { Done. https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... File test/mjsunit/induction-variable-turbofan.js (right): https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... test/mjsunit/induction-variable-turbofan.js:26: // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. On 2016/08/22 07:27:20, Jarin wrote: > Nit: you can use a shorter copyright. E.g., see test/mjsunit/array-push2.js. Done. https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... test/mjsunit/induction-variable-turbofan.js:31: // the corret upper and lower bounds. On 2016/08/22 07:27:20, Jarin wrote: > Nit: corret -> correct. Done. https://codereview.chromium.org/2260153002/diff/160001/test/mjsunit/induction... test/mjsunit/induction-variable-turbofan.js:43: if (i < 0) break; On 2016/08/22 07:27:20, Jarin wrote: > Could we change the i < 0 branches to return false? (They should never trigger.) Done.
Very nice! lgtm.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by franzih@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. Drive-by fix: Add lower bounds to lower_bounds zone vector instead of upper_bounds. BUG= ========== to ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. Drive-by fix: Add lower bounds to lower_bounds zone vector instead of upper_bounds. BUG= ==========
Message was sent while issue was closed.
Committed patchset #10 (id:180001)
Message was sent while issue was closed.
Description was changed from ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. Drive-by fix: Add lower bounds to lower_bounds zone vector instead of upper_bounds. BUG= ========== to ========== [turbofan] Induction variable bound analysis for decrements. This detects loops with integer decrements. Drive-by fix: Add lower bounds to lower_bounds zone vector instead of upper_bounds. BUG= Committed: https://crrev.com/6e665b094e7cbb6187fb59e3eb135266fa4c2e96 Cr-Commit-Position: refs/heads/master@{#38772} ==========
Message was sent while issue was closed.
Patchset 10 (id:??) landed as https://crrev.com/6e665b094e7cbb6187fb59e3eb135266fa4c2e96 Cr-Commit-Position: refs/heads/master@{#38772} |