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

Inline variable re-assignments #172

Open
laurentlb opened this issue Dec 9, 2022 · 0 comments
Open

Inline variable re-assignments #172

laurentlb opened this issue Dec 9, 2022 · 0 comments

Comments

@laurentlb
Copy link
Owner

  1. Even if we need the variable f, we can inline the last assignment here (since A is not used afterwards):
f+=r*smoothstep(.5,-1.,sunDir.y);
return f;
  1. We could get rid of the variable here, by inlining everything:
vec2 A=vec2(s,1.);
A=v(A,vec2(D,1.));
A=v(A,vec2(u,2.));
...
A=v(A,vec2(P,2.));
return A;

One way to detect these patterns is to introduce new variables when there's an assignment, similar to the SSA form (often seen in compilers). By introducing new variable names, detecting which ones are effectively constant, and aggressively inlining, we should be able to perform many optimizations.

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

No branches or pull requests

1 participant