6bead6bd00
This CL try to use a phi as a branch condition if the control flow from the branch is known from previous conditions. This change will open up more branch folding opportunities for later pass. Change-Id: I26316ab3a68c2d58d0df53691981288a996d4ba1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1674484 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#63434}
23 lines
687 B
JavaScript
23 lines
687 B
JavaScript
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
// Check that the branch elimination replace the redundant branch condition with
|
|
// a phi node, and then the branch is folded in EffectControlLinearizationPhase.
|
|
function foo(cond, v1, v2) {
|
|
cond = cond | 0;
|
|
var a = cond == 1 ? v1 : v2;
|
|
if(cond == 1) {
|
|
%TurbofanStaticAssert(a == v1);
|
|
} else {
|
|
%TurbofanStaticAssert(a == v2);
|
|
}
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
foo(1, 10, 20); foo(2, 30, 40);
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
foo(1, 10, 20); foo(2, 30, 40);
|