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

Implement constant folding in the frontend #7834

Closed
pcwalton opened this issue Jul 16, 2013 · 4 comments
Closed

Implement constant folding in the frontend #7834

pcwalton opened this issue Jul 16, 2013 · 4 comments
Labels
A-codegen Area: Code generation I-compiletime Issue: Problems and improvements with respect to compile times.

Comments

@pcwalton
Copy link
Contributor

We should be able to do constant folding in the frontend to eliminate "if" conditions that are never executed. It would also be nice to be able to call size_of at compile time in constants. (This latter part is an RFC.)

@alexcrichton
Copy link
Member

If size_of were always invoked as calling the compiler intrinsic directly, it might be fairly simple to evaluate things like compiler intrinsics at compile-time. It's behind the sys::size_of function, however, which the compiler knows nothing about. Basically I think that if we get size_of (unless we do something like pub use intrinsics::size_of in sys), we get generic CTFE (maybe a separate issue?)

@nikomatsakis
Copy link
Contributor

I imagine that size_of might have to be a keyword or some kind of built-in? This really depends on how hard we want to hold the line about what kinds of things get evaluated at compile-time.

dotdash added a commit to dotdash/rust that referenced this issue Jul 25, 2013
Until now, we only optimized away impossible branches when there is a
literal true/false in the code. But since the LLVM IR builder already does
constant folding for us, we can trivially expand that to work with
constants as well.

Refs rust-lang#7834
@pnkfelix
Copy link
Member

visiting for (long long delayed) triage. Should we consider differentiating between the two issues being described here? (I.e. one is a pure front-end optimization which could have great follow-on effects improving rustc performance; the second sounds like a user-visible feature, at least in its most general form...)

@steveklabnik
Copy link
Member

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#685

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-compiletime Issue: Problems and improvements with respect to compile times.
Projects
None yet
Development

No branches or pull requests

6 participants