-
Notifications
You must be signed in to change notification settings - Fork 803
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
Optimize integer for loop code gen #13573
Closed
Closed
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8b099b6
Integer n .. step .. m for loop optimization
albert-du 02bd0f9
run fantomas
albert-du 129e88a
Merge branch 'main' into for-loop-optimization
albert-du 86de1fd
add benchmark
albert-du 96fed0e
update quotations
albert-du 5b76d57
improve il generation
albert-du d771c5b
Update SurfaceArea.fs
albert-du 8889595
baseline tests
albert-du 65e6553
test near integer max
albert-du aa39f2b
fix integer overflow with constant step for loops
albert-du 606e15d
update baselines
albert-du c1c6bc4
test for loops in task
albert-du e1dc3c7
Update TheBigFileOfDebugStepping.fsx
albert-du 2afc973
Merge branch 'main' into for-loop-optimization
albert-du 0b93643
new benchmarks
albert-du 5d4441d
move optimizations out of type checking
albert-du 90154f1
Merge branch 'main' into for-loop-optimization
albert-du 76f22df
formatting
albert-du eb206ff
Merge branch 'for-loop-optimization' of https://github.com/albert-du/…
albert-du File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -665,6 +665,9 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | |
| FSharpForLoopUp -> QP.mkIntegerForLoop(ConvExpr cenv env lim0, ConvExpr cenv env lim1, ConvExpr cenv env body) | ||
| _ -> wfail(Error(FSComp.SR.crefQuotationsCantContainDescendingForLoops(), m)) | ||
|
||
| TOp.IntegerForLoop (_, _, _), [], [Expr.Lambda (_, _, _, [_], lim0, _, _);Expr.Lambda (_, _, _, [_], lim1, _, _);body; Expr.Lambda (_, _, _, [_], step, _, _)] -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm concerned by the addition of these new quotation constructs, see above |
||
QP.mkIntegerForLoopWithStep(ConvExpr cenv env lim0, ConvExpr cenv env lim1, ConvExpr cenv env body, ConvExpr cenv env step) | ||
|
||
| TOp.ILCall (_, _, _, isCtor, valUseFlag, isProperty, _, ilMethRef, enclTypeInst, methInst, _), [], callArgs -> | ||
let parentTyconR = ConvILTypeRefUnadjusted cenv m ilMethRef.DeclaringTypeRef | ||
let isNewObj = isCtor || (match valUseFlag with CtorValUsedAsSuperInit | CtorValUsedAsSelfInit -> true | _ -> false) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we may need to guard this via a language version switch or move this to an optimization phase (though that is painful). It changes the form of quotations for these constructs which is a breaking change.
Quoting these loops is rare but it's also more philosophical: we shouldn't be adding any optimizations which change the quoted form or require new additions to the quotations API. So optimziations should be in later phases.