Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: allow reordering of loadlocal after last assignment #29668

Closed
wants to merge 5 commits into from

Conversation

josephsavona
Copy link
Contributor

@josephsavona josephsavona commented May 30, 2024

Stack from ghstack (oldest at bottom):

Extends the instruction reordering from the previous PR to allow reordering LoadLocal, but only after the last assignment of the loaded variable.

Thus if we have:

t0 = StoreLocal const x = ...
t1 = LoadLocal x
t2 = foo
t3 = bar t1 # t1 used here

We know that x isn't assigned after the first instruction, and can safely reorder the loadlocal to where it's first used:

t0 = StoreLocal const x = ...
t2 = foo
t1 = LoadLocal x
t3 = bar t1

Note that this assumes each LoadLocal temporary is used exactly once, which we already guarantee in BuildHIR.

Copy link

vercel bot commented May 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 5:35pm

josephsavona added a commit that referenced this pull request May 30, 2024
ghstack-source-id: f134097b97884f63f4f9d7c643839eb07c83deee
Pull Request resolved: #29668
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels May 30, 2024
josephsavona added a commit that referenced this pull request May 30, 2024
ghstack-source-id: 804744fb562ea3639090a0c4c6cefa871a6aa9c0
Pull Request resolved: #29668
@react-sizebot
Copy link

react-sizebot commented May 30, 2024

Comparing: c4b433f...a1bd51e

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.66 kB 6.66 kB = 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.26 kB 497.26 kB = 89.11 kB 89.11 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.08 kB 502.08 kB = 89.80 kB 89.80 kB
facebook-www/ReactDOM-prod.classic.js = 594.56 kB 594.56 kB = 104.72 kB 104.72 kB
facebook-www/ReactDOM-prod.modern.js = 570.95 kB 570.95 kB = 101.13 kB 101.13 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Generated by 🚫 dangerJS against a1bd51e

…ent"

Extends the instruction reordering from the previous PR to allow reordering LoadLocal, but only after the last assignment of the loaded variable.

Thus if we have:

```
t0 = StoreLocal const x = ...
t1 = LoadLocal x
t2 = foo
t3 = bar t1 # t1 used here
```

We know that x isn't assigned after the first instruction, and can safely reorder the loadlocal to where it's first used:

```
t0 = StoreLocal const x = ...
t2 = foo
t1 = LoadLocal x
t3 = bar t1
```

Note that this assumes each LoadLocal temporary is used exactly once, which we already guarantee in BuildHIR.

[ghstack-poisoned]
josephsavona added a commit that referenced this pull request May 30, 2024
Extends the instruction reordering from the previous PR to allow reordering LoadLocal, but only after the last assignment of the loaded variable.

Thus if we have:

```
t0 = StoreLocal const x = ...
t1 = LoadLocal x
t2 = foo
t3 = bar t1 # t1 used here
```

We know that x isn't assigned after the first instruction, and can safely reorder the loadlocal to where it's first used:

```
t0 = StoreLocal const x = ...
t2 = foo
t1 = LoadLocal x
t3 = bar t1
```

Note that this assumes each LoadLocal temporary is used exactly once, which we already guarantee in BuildHIR.

ghstack-source-id: 804744fb562ea3639090a0c4c6cefa871a6aa9c0
Pull Request resolved: #29668
@josephsavona josephsavona marked this pull request as draft May 30, 2024 19:51
Copy link

@haeven-kelley haeven-kelley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third test still failing

…ent"

Extends the instruction reordering from the previous PR to allow reordering LoadLocal, but only after the last assignment of the loaded variable.

Thus if we have:

```
t0 = StoreLocal const x = ...
t1 = LoadLocal x
t2 = foo
t3 = bar t1 # t1 used here
```

We know that x isn't assigned after the first instruction, and can safely reorder the loadlocal to where it's first used:

```
t0 = StoreLocal const x = ...
t2 = foo
t1 = LoadLocal x
t3 = bar t1
```

Note that this assumes each LoadLocal temporary is used exactly once, which we already guarantee in BuildHIR.

[ghstack-poisoned]
josephsavona added a commit that referenced this pull request Jun 3, 2024
Extends the instruction reordering from the previous PR to allow reordering LoadLocal, but only after the last assignment of the loaded variable.

Thus if we have:

```
t0 = StoreLocal const x = ...
t1 = LoadLocal x
t2 = foo
t3 = bar t1 # t1 used here
```

We know that x isn't assigned after the first instruction, and can safely reorder the loadlocal to where it's first used:

```
t0 = StoreLocal const x = ...
t2 = foo
t1 = LoadLocal x
t3 = bar t1
```

Note that this assumes each LoadLocal temporary is used exactly once, which we already guarantee in BuildHIR.

ghstack-source-id: 8781cb6763f87a593b92583df6a3fbc368e078e7
Pull Request resolved: #29668
t1 = $[2];
}
return t1;
return <>{posts}</>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is weird. technically correct - posts will always invalidate, so no point memoizing the jsx - but i want to double-check why the memo is getting removed here

…ent"

Extends the instruction reordering from the previous PR to allow reordering LoadLocal, but only after the last assignment of the loaded variable.

Thus if we have:

```
t0 = StoreLocal const x = ...
t1 = LoadLocal x
t2 = foo
t3 = bar t1 # t1 used here
```

We know that x isn't assigned after the first instruction, and can safely reorder the loadlocal to where it's first used:

```
t0 = StoreLocal const x = ...
t2 = foo
t1 = LoadLocal x
t3 = bar t1
```

Note that this assumes each LoadLocal temporary is used exactly once, which we already guarantee in BuildHIR.

[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants