Commit e6d84f4e authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[csa] fix variable merge for switch default label

Bug: 
Change-Id: I52e757aa2de951ff40660545472321c7dec84241
Reviewed-on: https://chromium-review.googlesource.com/632156Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48167}
parent e0b76c9a
......@@ -1208,8 +1208,8 @@ void CodeAssembler::Switch(Node* index, Label* default_label,
for (size_t i = 0; i < case_count; ++i) {
labels[i] = case_labels[i]->label_;
case_labels[i]->MergeVariables();
default_label->MergeVariables();
}
default_label->MergeVariables();
return raw_assembler()->Switch(index, default_label->label_, case_values,
labels, case_count);
}
......
......@@ -2473,6 +2473,7 @@ void InstructionSelector::VisitOsrValue(Node* node) {
void InstructionSelector::VisitPhi(Node* node) {
const int input_count = node->op()->ValueInputCount();
DCHECK_EQ(input_count, current_block_->PredecessorCount());
PhiInstruction* phi = new (instruction_zone())
PhiInstruction(instruction_zone(), GetVirtualRegister(node),
static_cast<size_t>(input_count));
......
......@@ -4,6 +4,8 @@
#include "src/code-factory.h"
#include "src/compiler/code-assembler.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/opcodes.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "test/cctest/compiler/code-assembler-tester.h"
......@@ -309,18 +311,23 @@ TEST(VariableMergeSwitch) {
Label l1(&m), l2(&m), default_label(&m);
Label* labels[] = {&l1, &l2};
int32_t values[] = {1, 2};
Node* temp = m.Int32Constant(0);
var1.Bind(temp);
Node* temp1 = m.Int32Constant(0);
var1.Bind(temp1);
m.Switch(m.Int32Constant(2), &default_label, values, labels, 2);
m.Bind(&l1);
DCHECK_EQ(temp, var1.value());
m.Return(temp);
CHECK_EQ(temp1, var1.value());
m.Return(temp1);
m.Bind(&l2);
DCHECK_EQ(temp, var1.value());
m.Return(temp);
CHECK_EQ(temp1, var1.value());
Node* temp2 = m.Int32Constant(7);
var1.Bind(temp2);
m.Goto(&default_label);
m.Bind(&default_label);
DCHECK_EQ(temp, var1.value());
m.Return(temp);
CHECK_EQ(IrOpcode::kPhi, var1.value()->opcode());
CHECK_EQ(2, var1.value()->op()->ValueInputCount());
CHECK_EQ(temp1, NodeProperties::GetValueInput(var1.value(), 0));
CHECK_EQ(temp2, NodeProperties::GetValueInput(var1.value(), 1));
m.Return(temp1);
}
TEST(SplitEdgeBranchMerge) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment