diff --git a/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts b/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts index 9da0bba5d9..0cffa408c7 100644 --- a/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts +++ b/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts @@ -106,19 +106,20 @@ export function eliminateRedundantPhi( for (const place of eachInstructionOperand(instr)) { rewritePlace(place, rewrites); } - if (instr.value.kind === "FunctionExpression") { + + if ( + instr.value.kind === "FunctionExpression" && + fn.env.enableOptimizeFunctionExpressions + ) { const { context } = instr.value.loweredFunc; for (const place of context) { rewritePlace(place, rewrites); } - } - // visit function expressions on first iteration of each block - if ( - isFirstIteration && - instr.value.kind === "FunctionExpression" && - fn.env.enableOptimizeFunctionExpressions - ) { - eliminateRedundantPhi(instr.value.loweredFunc, rewrites); + + // visit function expressions on first iteration of each block + if (isFirstIteration) { + eliminateRedundantPhi(instr.value.loweredFunc, rewrites); + } } }