-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
There was a problem hiding this 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! ☀️
if(!e) { a } else { b } is now transformed into if(e) { b } else { a }
This case was intentionally not included.
On benchmarking that I did for original optimization this stopped branches
from being merged by further optimizations
…On 13 November 2017 08:05:19 gan_ ***@***.***> wrote:
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 }`
You can view, comment on, or merge this pull request online at:
#3466
-- Commit Summary --
* Merge remote-tracking branch 'origin/const-fold' into wip-local-opt
-- File Changes --
M compiler/src/dotty/tools/dotc/transform/localopt/ConstantFold.scala (38)
M compiler/test/dotty/tools/dotc/SimplifyTests.scala (62)
-- Patch Links --
https://github.com/lampepfl/dotty/pull/3466.patch
https://github.com/lampepfl/dotty/pull/3466.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#3466
|
@@ -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_! => |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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 intoif(e) { b } else { a }