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

my int $x; ( $x += 42 is slower than $x = $x + 42) #1329

Closed
zoffixznet opened this issue Dec 22, 2017 · 1 comment
Closed

my int $x; ( $x += 42 is slower than $x = $x + 42) #1329

zoffixznet opened this issue Dec 22, 2017 · 1 comment

Comments

@zoffixznet
Copy link
Contributor

$ perl6 -e 'my int $i = 42; for ^1000000 { $i = $i + 10 }; say now - INIT now'
0.36127593
$ perl6 -e 'my int $i = 42; for ^1000000 { $i += 10 }; say now - INIT now'
0.5772323
$ perl6 -v
This is Rakudo version 2017.11-8-g7939014 built on MoarVM version 2017.11

Looking at --target=optimize's ASTs, I see that while $i += 10 does get rewritten to $i = $i + 10, it misses optimization that converts &infix:<+> call into an nqp::add_i

clarkema added a commit to clarkema/advent-of-code that referenced this issue Dec 22, 2017
Ran through the Perl 6 implementation of day 05 part 2 with the
help of #perl6, improving the performance from 1m20s to 0m13s.

Resulted in two new Rakudo issues for future improvements:

rakudo/rakudo#1328
rakudo/rakudo#1329
@zoffixznet
Copy link
Contributor Author

This was fixed with 5dd9ed1

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

No branches or pull requests

1 participant