From 3d3ad1b9ef6b5b7bd3e4859b5461deb138389e41 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Tue, 24 Oct 2023 16:09:08 +0100 Subject: [PATCH] [LeaveSSA] Process all phis in a block I don't know if it's possible to write a test for this as I can't seem to get the codegen to change. For the following testcase: ``` function useFoo(setOne) { let x; let y; if (setOne) { x = 1; y = 3; } else { x = 2; y = 5; } return { x, y }; } ``` The LeaveSSA changes from: ``` .... bb1 (block): predecessor blocks: bb2 bb3 x$36:TPrimitive: phi(bb2: x$19, bb3: x$19) y$21[8:14]:TPrimitive: phi(bb2: y$21, bb3: y$21) ... ``` to ``` ... bb1 (block): predecessor blocks: bb2 bb3 x$36:TPrimitive: phi(bb2: x$19, bb3: x$19) y$38:TPrimitive: phi(bb2: y$21, bb3: y$21) ... ``` Notice how `y`'s reassignment got skipped previously. --- compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts b/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts index e557673ea1..22fc6581ca 100644 --- a/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts +++ b/compiler/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts @@ -322,7 +322,7 @@ export function leaveSSA(fn: HIRFunction): void { operand.mutableRange.end = phi.id.mutableRange.end; } } - return; + continue; } // Otherwise this is a temporary phi (logical or ternary) or occurs in a loop. In either // case we can't independently memoize any of the values: unify their ranges to span the