Skip to content

Commit 4e4bfa0

Browse files
author
Mark Seaborn
committed
i64: Handle i64 values in phi nodes
1 parent 9881d1d commit 4e4bfa0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

codegen.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,10 +509,14 @@ void handle_phi_nodes(llvm::BasicBlock *from_bb,
509509
llvm::PHINode *phi = llvm::dyn_cast<llvm::PHINode>(inst);
510510
if (!phi)
511511
break;
512+
llvm::Value *incoming = phi->getIncomingValueForBlock(from_bb);
512513
if (is_i64(phi->getType())) {
513-
codebuf.unhandled_case("i64 in PHINode");
514+
codebuf.move_part_to_reg(tmp_reg, incoming, 0);
515+
codebuf.spill_part(tmp_reg, phi, 0);
516+
codebuf.move_part_to_reg(tmp_reg, incoming, 4);
517+
codebuf.spill_part(tmp_reg, phi, 4);
514518
} else {
515-
codebuf.move_to_reg(tmp_reg, phi->getIncomingValueForBlock(from_bb));
519+
codebuf.move_to_reg(tmp_reg, incoming);
516520
codebuf.spill(tmp_reg, phi);
517521
}
518522
}

codegen_test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ void test_features() {
250250
ASSERT_EQ(func(99), 123);
251251
ASSERT_EQ(func(98), 456);
252252

253+
{
254+
uint64_t (*funcp)(uint64_t arg);
255+
GET_FUNC(funcp, "test_phi_i64");
256+
ASSERT_EQ(funcp(99), 123);
257+
ASSERT_EQ(funcp(98), 456);
258+
}
259+
253260
GET_FUNC(func, "test_select");
254261
ASSERT_EQ(func(99), 123);
255262
ASSERT_EQ(func(98), 456);

0 commit comments

Comments
 (0)