Repository navigation
Conversation
…efaults Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6bf496d3-1e66-480a-9422-ffbb190b207e
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
@MihuBot -nuget |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6bf496d3-1e66-480a-9422-ffbb190b207e
…hecks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6bf496d3-1e66-480a-9422-ffbb190b207e
Member
Author
|
@MihuBot -nuget |
This was referenced Nov 26, 2026
EgorBo
added a commit
that referenced
this pull request
Nov 30, 2026
Follow up to #137936 (split out of #138311). `optAssertionProp_Cast` now falls back to KnownBitsAnalysis when RangeCheck can't prove that the cast operand is in range. That lets it drop redundant casts and clear overflow checks. The analysis also got more precise: * Signed bounds for sign-extended values (small signed types, `int -> long` casts). * Bounds flow through value-preserving casts. * `x != cns` assertions refine bounds when `cns` is one of them. * `otherVN relop vn` assertions are used in addition to `vn relop otherVN`. * 32-bit PHIs are followed (previously only 64-bit). ## Examples ```cs // int * 10000 always fits into long: TimeSpan range checks removed (System.Runtime.Caching) TimeSpan PollingInterval => TimeSpan.FromMilliseconds(_configPollingInterval); // int field // Range of r is [0..510], checked((byte)r) doesn't need an overflow check under r <= 255 (Microsoft.VisualBasic) object AddByte(byte x, byte y) { short r = (short)(x + y); return r > byte.MaxValue ? r : checked((byte)r); } // redundant zero-extension removed (System.Formats.Asn1) Asn1Tag AsPrimitive() => new Asn1Tag((byte)(_controlFlags & ~ConstructedMask), TagValue); // byte field ``` --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6bf496d3-1e66-480a-9422-ffbb190b207e
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #110315
Closes #10634
Closes #10830
Closes #134380
Closes #9426 (partially fixed by the previous KnownBits PR)
Closes #134444 (partially fixed by the previous KnownBits PR)
Follow up to #137936. KnownBitsAnalysis was only used to fold relops; now assertion prop also uses it for:
optAssertionProp_Cast): remove overflow checks and redundant extensions.optAssertionProp_AddMulSub): clearGTF_OVERFLOWwhen the result provably fits.optAssertionProp_BndsChk): drop the check whenindex u< lengthis proven by known bits/bounds.The analysis itself also got smarter:
x != cnsassertions refine bounds whencnsis one of them.int -> longcasts).otherVN relop vnassertions are used in addition tovn relop otherVN.[0..Array.MaxLength].Plus a small morph fix for #134380: narrow
(long & C1) == C2to 32-bit when the constants fit into 32 bits unsigned.Examples