-
Notifications
You must be signed in to change notification settings - Fork 47.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified version of the example. As I eventually uncovered in #1342, the issue is cascading redundant phis not getting rewritten.
- Loading branch information
1 parent
6d4b0c6
commit ff855b1
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
compiler/forget/src/__tests__/fixtures/hir/_bug.ssa.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
function Component(props) { | ||
let x = 0; | ||
const values = []; | ||
const y = props.a || props.b; | ||
values.push(y); | ||
if (props.c) { | ||
x = 1; | ||
} | ||
values.push(x); | ||
if (props.d) { | ||
x = 2; | ||
} | ||
values.push(x); | ||
return values; | ||
} | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
function Component(props) { | ||
const $ = React.unstable_useMemoCache(4); | ||
const c_0 = $[0] !== props; | ||
let values; | ||
if (c_0) { | ||
values = []; | ||
const c_2 = $[2] !== props; | ||
let t0; | ||
if (c_2) { | ||
t0 = props.a || props.b; | ||
$[2] = props; | ||
$[3] = t0; | ||
} else { | ||
t0 = $[3]; | ||
} | ||
const y = t0; | ||
values.push(y); | ||
let x$0 = x; | ||
if (props.c) { | ||
x = 1; | ||
} | ||
|
||
values.push(x$0); | ||
if (props.d) { | ||
x = 2; | ||
} | ||
|
||
values.push(x); | ||
$[0] = props; | ||
$[1] = values; | ||
} else { | ||
values = $[1]; | ||
} | ||
return values; | ||
} | ||
|
||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function Component(props) { | ||
let x = 0; | ||
const values = []; | ||
const y = props.a || props.b; | ||
values.push(y); | ||
if (props.c) { | ||
x = 1; | ||
} | ||
values.push(x); | ||
if (props.d) { | ||
x = 2; | ||
} | ||
values.push(x); | ||
return values; | ||
} |