-
Notifications
You must be signed in to change notification settings - Fork 5.4k
JIT: Fix fgFoldCondToReturnBlock for multi-statement return blocks #124642
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
Merged
jakobbotsch
merged 4 commits into
dotnet:main
from
yykkibbb:fix/constant-folded-operand-codegen-123621
Mar 23, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ce08187
JIT: Fix fgFoldCondToReturnBlock for multi-statement return blocks (#…
yykkibbb 8a2123e
Move test to JIT/opt/OptimizeBools per review feedback (#123621)
yykkibbb 74defde
JIT: Fix VN-based dead store removal for unused SSA defs (#123621)
yykkibbb 37bc0a7
Revert VN-based dead store removal changes per review feedback (#123621)
yykkibbb 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 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| // When a constant-folded operand appears after a non-constant operand in a | ||
| // short-circuit && expression, inlining may leave dead local stores in the | ||
| // return block. fgFoldCondToReturnBlock failed to optimize this pattern | ||
| // because isReturnBool required hasSingleStmt(), which was false due to the | ||
| // leftover dead stores. | ||
|
|
||
| using System; | ||
| using System.Runtime.CompilerServices; | ||
| using Xunit; | ||
|
|
||
| public class Runtime_123621 | ||
| { | ||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public static bool Hoisted(byte v) | ||
| { | ||
| bool isUnix = Environment.NewLine != "\r\n"; | ||
| return (v == 2 && isUnix); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public static bool Inline_Before(byte v) | ||
| { | ||
| return (Environment.NewLine != "\r\n" && v == 2); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| public static bool Inline_After(byte v) | ||
| { | ||
| return (v == 2 && Environment.NewLine != "\r\n"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public static void TestEntryPoint() | ||
| { | ||
| bool isUnix = Environment.NewLine != "\r\n"; | ||
|
|
||
| Assert.Equal(isUnix, Hoisted(2)); | ||
| Assert.False(Hoisted(3)); | ||
|
|
||
| Assert.Equal(isUnix, Inline_Before(2)); | ||
| Assert.False(Inline_Before(3)); | ||
|
|
||
| Assert.Equal(isUnix, Inline_After(2)); | ||
| Assert.False(Inline_After(3)); | ||
|
|
||
| // All three methods must produce the same result. | ||
| Assert.Equal(Hoisted(2), Inline_After(2)); | ||
| Assert.Equal(Inline_Before(2), Inline_After(2)); | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <DebugType>PdbOnly</DebugType> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs" /> | ||
| </ItemGroup> | ||
| </Project> |
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.
Uh oh!
There was an error while loading. Please reload this page.