From ab9bc3b13c181159d1e5e698a01384985fef2fa7 Mon Sep 17 00:00:00 2001 From: Nico Reissmann Date: Thu, 19 Mar 2026 05:17:24 +0100 Subject: [PATCH 1/2] InvariantValueRedirection: divert invariant theta IO states --- jlm/llvm/opt/InvariantValueRedirection.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/jlm/llvm/opt/InvariantValueRedirection.cpp b/jlm/llvm/opt/InvariantValueRedirection.cpp index b00773ce85..2c1b7d3572 100644 --- a/jlm/llvm/opt/InvariantValueRedirection.cpp +++ b/jlm/llvm/opt/InvariantValueRedirection.cpp @@ -202,11 +202,6 @@ InvariantValueRedirection::redirectThetaOutputs(rvsdg::ThetaNode & thetaNode) { for (const auto & loopVar : thetaNode.GetLoopVars()) { - // FIXME: In order to also redirect I/O state type variables, we need to know whether a loop - // terminates. - if (rvsdg::is(loopVar.input->Type())) - continue; - if (rvsdg::ThetaLoopVarIsInvariant(loopVar)) loopVar.output->divert_users(loopVar.input->origin()); } From 6b8d9ab7b0faecac8fb84d9fe0406c55aef859fe Mon Sep 17 00:00:00 2001 From: Nico Reissmann Date: Thu, 19 Mar 2026 05:51:20 +0100 Subject: [PATCH 2/2] fix unit test --- .../opt/InvariantValueRedirectionTests.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/jlm/llvm/opt/InvariantValueRedirectionTests.cpp b/tests/jlm/llvm/opt/InvariantValueRedirectionTests.cpp index 5541ccb751..b7a89477f8 100644 --- a/tests/jlm/llvm/opt/InvariantValueRedirectionTests.cpp +++ b/tests/jlm/llvm/opt/InvariantValueRedirectionTests.cpp @@ -102,14 +102,14 @@ TEST(InvariantValueRedirectionTests, TestTheta) rvsdg.GetRootRegion(), jlm::llvm::LlvmLambdaOperation::Create(functionType, "test", Linkage::externalLinkage)); - auto c = lambdaNode->GetFunctionArguments()[0]; - auto x = lambdaNode->GetFunctionArguments()[1]; - auto l = lambdaNode->GetFunctionArguments()[2]; + const auto controlArgument = lambdaNode->GetFunctionArguments()[0]; + const auto valueArgument = lambdaNode->GetFunctionArguments()[1]; + const auto ioStateArgument = lambdaNode->GetFunctionArguments()[2]; auto thetaNode1 = jlm::rvsdg::ThetaNode::create(lambdaNode->subregion()); - auto thetaVar1 = thetaNode1->AddLoopVar(c); - auto thetaVar2 = thetaNode1->AddLoopVar(x); - auto thetaVar3 = thetaNode1->AddLoopVar(l); + auto thetaVar1 = thetaNode1->AddLoopVar(controlArgument); + auto thetaVar2 = thetaNode1->AddLoopVar(valueArgument); + auto thetaVar3 = thetaNode1->AddLoopVar(ioStateArgument); auto thetaNode2 = jlm::rvsdg::ThetaNode::create(thetaNode1->subregion()); auto thetaVar4 = thetaNode2->AddLoopVar(thetaVar1.pre); @@ -129,9 +129,9 @@ TEST(InvariantValueRedirectionTests, TestTheta) RunInvariantValueRedirection(*rvsdgModule); // Assert - EXPECT_EQ(lambdaNode->GetFunctionResults()[0]->origin(), c); - EXPECT_EQ(lambdaNode->GetFunctionResults()[1]->origin(), x); - EXPECT_EQ(lambdaNode->GetFunctionResults()[2]->origin(), thetaVar3.output); + EXPECT_EQ(lambdaNode->GetFunctionResults()[0]->origin(), controlArgument); + EXPECT_EQ(lambdaNode->GetFunctionResults()[1]->origin(), valueArgument); + EXPECT_EQ(lambdaNode->GetFunctionResults()[2]->origin(), ioStateArgument); } TEST(InvariantValueRedirectionTests, TestCall)