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

Comments

Projects
None yet
6 participants
@pcwalton
Contributor

pcwalton commented Jul 16, 2013

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

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Jul 17, 2013

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?)

Member

alexcrichton commented Jul 17, 2013

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

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Jul 17, 2013

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.

Contributor

nikomatsakis commented Jul 17, 2013

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

Make omission of impossible if-else branches work with constants
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 #7834
@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Jan 23, 2014

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...)

Member

pnkfelix commented Jan 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Jan 21, 2015

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

Member

steveklabnik commented Jan 21, 2015

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