Skip to content

Constant folding improvements #3466

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

Merged
merged 1 commit into from
Nov 20, 2017
Merged

Conversation

gan74
Copy link
Contributor

@gan74 gan74 commented Nov 13, 2017

Expressions with constant type are now folded correctly.
ConstantFold doesn't call typer's ConstFold.apply on every expression making it faster.
if(!e) { a } else { b } is now transformed into if(e) { b } else { a }

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@DarkDimius
Copy link
Contributor

DarkDimius commented Nov 13, 2017 via email

@@ -76,9 +77,6 @@ import Simplify.desugarIdent
// cond.select(defn.Boolean_&&).appliedTo(elsep)
// the other case ins't handled intentionally. See previous case for explanation

case If(t @ Select(recv, _), thenp, elsep) if t.symbol eq defn.Boolean_! =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, in the PR description you say that if(!e) { a } else { b } now if(e) { b } else { a }, but it seams that you just removed the case doing that... Could you had a test for this example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, I looked into it: you are right. It's an error on my part, I didn't add the feature, I only added documentation for it.

Sorry or the confusion...

Expressions with constant type are now folded correctly.
ConstantFold doesn't call typer's ConstFold.apply on every expression making it faster
Copy link
Contributor

@OlivierBlanvillain OlivierBlanvillain left a comment

Choose a reason for hiding this comment

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

LGTM!

@gan74 gan74 changed the title WIP: Constant folding improvements Constant folding improvements Nov 15, 2017
@allanrenucci allanrenucci merged commit b76358f into scala:master Nov 20, 2017
@gan74 gan74 deleted the wip-local-opt branch December 13, 2017 22:31
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

Successfully merging this pull request may close these issues.

5 participants