Skip to content

Commit 71442c8

Browse files
Computed collections: simple count check (#16947)
* Use count = 0 instead of count < 1 * The count < 1 check was a vestige of an older approach for computing the count that could result in a negative count. * Update baselines * Update release notes
1 parent 06c85f0 commit 71442c8

File tree

5 files changed

+2205
-2320
lines changed

5 files changed

+2205
-2320
lines changed

docs/release-notes/.FSharp.Compiler.Service/8.0.300.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@
5454
* 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))
5555
* Refactored parenthesization API. ([PR #16461])(https://github.com/dotnet/fsharp/pull/16461))
5656
* Optimize some interpolated strings by lowering to string concatenation. ([PR #16556](https://github.com/dotnet/fsharp/pull/16556))
57-
* Integral range optimizations. ([PR #16650](https://github.com/dotnet/fsharp/pull/16650), [PR #16832](https://github.com/dotnet/fsharp/pull/16832))
57+
* 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))

src/Compiler/Optimize/LowerComputedCollections.fs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,7 @@ module Array =
393393
mkCompGenLetIn m (nameof count) (tyOfExpr g count) count (fun (_, count) ->
394394
let countTy = tyOfExpr g count
395395

396-
// count < 1
397-
let countLtOne =
398-
if isSignedIntegerTy g countTy then
399-
mkILAsmClt g m count (mkTypedOne g m countTy)
400-
else
401-
mkAsmExpr ([AI_clt_un], [], [count; mkTypedOne g m countTy], [g.bool_ty], m)
402-
403-
// if count < 1 then
396+
// if count = 0 then
404397
// [||]
405398
// else
406399
// let array = (# "newarr !0" type ('T) count : 'T array #) in
@@ -410,7 +403,7 @@ module Array =
410403
DebugPointAtBinding.NoneAtInvisible
411404
m
412405
arrayTy
413-
countLtOne
406+
(mkILAsmCeq g m count (mkTypedZero g m countTy))
414407
(mkArray (overallElemTy, [], m))
415408
(mkArrayInit count mkLoop)
416409
)

0 commit comments

Comments
 (0)