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

constant propagation in ranged type limits #505

Conversation

riederm
Copy link
Collaborator

@riederm riederm commented Jun 21, 2022

added a test that shows that constants are propagated even in
ranged-type's limits, so even if you use (const-)expressions (a+b)
to define the limits of a ranged type, the const-expressions
will be evaluated during compile time and the result will be used.

  • as in contrast we would do this calculation all the time at
    runtime.

the behavior was introduced in PR #504 (016328)

fixes #350

added a test that shows that constants are propagated even in
ranged-type's limits, so even if you use (const-)expressions (a+b)
to define the limits of a ranged type, the const-expressions
will be evaluated during compile time and the result will be used.
- as in contrast we would do this calculation all the time at
runtime.

the behavior was introduced in PR #504 (016328)

fixes #350
@riederm riederm force-pushed the 350-optimization-using-const-expression-in-sub-range-statements-should-resolve-constant-expressions-in-codegen branch from 12d0580 to e369a37 Compare June 21, 2022 21:53
@riederm
Copy link
Collaborator Author

riederm commented Jun 21, 2022

see attached issue, previosuly we generated whole lot of stuff for the call to the check-range function.
now the min & max values are propagated (inlined) since they are constants

%call = call i16 @CheckRangeSigned(i16 5, i16 0, i16 8)
                                   ^^^^^^ ^^^^^  ^^^^^

@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2022

Codecov Report

Merging #505 (e369a37) into master (0163281) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #505   +/-   ##
=======================================
  Coverage   93.03%   93.03%           
=======================================
  Files          40       40           
  Lines       14468    14468           
=======================================
  Hits        13461    13461           
  Misses       1007     1007           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0163281...e369a37. Read the comment docs.

@riederm riederm requested review from 99NIMI and ghaith June 21, 2022 22:11
…-sub-range-statements-should-resolve-constant-expressions-in-codegen
@ghaith ghaith merged commit d667f20 into master Jun 22, 2022
@ghaith ghaith deleted the 350-optimization-using-const-expression-in-sub-range-statements-should-resolve-constant-expressions-in-codegen branch June 22, 2022 13:53
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.

Optimization: using const-expression in Sub-Range-Statements should resolve constant expressions in codegen
3 participants