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

Computed collections: simple count check #16947

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
* Reverted [#16348](https://github.com/dotnet/fsharp/pull/16348) `ThreadStatic` `CancellationToken` changes to improve test stability and prevent potential unwanted cancellations. ([PR #16536](https://github.com/dotnet/fsharp/pull/16536))
* Refactored parenthesization API. ([PR #16461])(https://github.com/dotnet/fsharp/pull/16461))
* Optimize some interpolated strings by lowering to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556))
* Integral range optimizations. ([PR #16650](https://github.com/dotnet/fsharp/pull/16650), [PR #16832](https://github.com/dotnet/fsharp/pull/16832))
* Integral range optimizations. ([PR #16650](https://github.com/dotnet/fsharp/pull/16650), [PR #16832](https://github.com/dotnet/fsharp/pull/16832), [PR #16947](https://github.com/dotnet/fsharp/pull/16947))
11 changes: 2 additions & 9 deletions src/Compiler/Optimize/LowerComputedCollections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,7 @@ module Array =
mkCompGenLetIn m (nameof count) (tyOfExpr g count) count (fun (_, count) ->
let countTy = tyOfExpr g count

// count < 1
let countLtOne =
if isSignedIntegerTy g countTy then
mkILAsmClt g m count (mkTypedOne g m countTy)
else
mkAsmExpr ([AI_clt_un], [], [count; mkTypedOne g m countTy], [g.bool_ty], m)

// if count < 1 then
// if count = 0 then
// [||]
// else
// let array = (# "newarr !0" type ('T) count : 'T array #) in
Expand All @@ -410,7 +403,7 @@ module Array =
DebugPointAtBinding.NoneAtInvisible
m
arrayTy
countLtOne
(mkILAsmCeq g m count (mkTypedZero g m countTy))
(mkArray (overallElemTy, [], m))
(mkArrayInit count mkLoop)
)
Expand Down
Loading
Loading