Repository navigation
Preserve integer identity for Boolean arithmetic slots - #9946
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Round 1 is complete for PR 9946.
Progress: 1 pushed candidate, 1 usable review, 1 accepted finding. Resolution: Accepted the finding. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Round 2 candidate is published at exact head It resolves the accepted round 1 finding by limiting Boolean candidate loads Validation at this head:
|
|
Round 2 is complete for PR 9946.
Progress: 2 pushed candidates, 2 usable reviews, 1 accepted finding. Resolution: The round 1 finding is resolved. Boolean candidate-load selection now admits only Boolean or |
dotnet-inspectbuilds robust, capable .NET inspection features that provide foundational capabilities or compelling experiences and are conventionally sound, delightfully new or unique, or both.Summary
System.Int32identity for complete slot webs produced by Boolean/intarithmetic before Boolean operands are normalized tocondition ? 1 : 0.UnrenderableStoreTypesplit webs without adding broad residual testimony or enum inference.TypeRef.FunctionPointerParameterTextsplit because its Boolean branch encodesArgumentRefKindand requires separate enum-specific proof.Part of #9371.
Design basis
Normative owner:
docs/design/value-typed-emission.md#bounded-i4-slot-identity-preservation.ArithmeticBoolOperandPassowns integer identity only for complete slot webs whose stores and loads stay inside its exact Boolean/System.Int32arithmetic domain.BooleanFoldingPassowns Boolean materialization only when omitted uses cannot belong to the same I4 storage family. Arbitrary Boolean producers, non-Int32arithmetic, enum identity, mixed scopes, and non-arithmetic observers remain outside these rules.Demo
Roslyn 5.0.0's
ForEachLoopOperation.get_ChildOperationsCountcomputes a count from twoBoolean comparisons, stores it, and later adds it to two more counts.
The checksum-matched PDB/SourceLink oracle is:
Source:
https://raw.githubusercontent.com/dotnet/roslyn/6c4a46a31302167b425d5e0a31ea83c9a9aa1d09/src/Compilers/Core/Portable/Generated/Operations.Generated.cs
Exact base
d93cb58f8split the same stack slot into an integer producer and anunassigned Boolean consumer, then narrowed the multi-term count back to
zero-or-one:
Exact reviewed head
a48017a48preserves the slot's integer identity andreuses the actual count directly:
Evidence
dotnet build dotnet-inspect.slnx -c Release: succeeded with 0 warnings and 0 errors.including unrelated
Int64same-number reuse.d93cb58f8:UnrenderableStoreType: 5 webs / 10 locals -> 1 web / 2 locals;ForEachLoopOperation.get_ChildOperationsCountandForToLoopOperation.get_ChildOperationsCount, keeps mixed integer stores inEarlyWellKnownAttributeBinder.CanBeValidAttributeArgument, and retains the integer count inEhStructuringPass.InlineFilterLocalLoads.6f846c49b, including three direct residual-census setups missingDefiniteAssignmentPass, two invalid caller-supplied corpus-sensor pipelines, and five existing fidelity/compile-back expectations.npx markdownlint-cli docs/design/value-typed-emission.mdandgit diff --check origin/main...HEADpassed.