Skip to content

JIT: Treat store in JTRUE block as the ElseOperation in if-conversion#124738

Draft
BoyBaykiller wants to merge 15 commits intodotnet:mainfrom
BoyBaykiller:if-conv-unconditional-store-to-else-124713
Draft

JIT: Treat store in JTRUE block as the ElseOperation in if-conversion#124738
BoyBaykiller wants to merge 15 commits intodotnet:mainfrom
BoyBaykiller:if-conv-unconditional-store-to-else-124713

Conversation

@BoyBaykiller
Copy link
Contributor

If-conversion phase now produces the same IR for these two cases:

void First(int tMinLeft, int tMinRight)
{
    bool leftCloser = false;
    if (tMinLeft < tMinRight)
    {
        leftCloser = true;
    }
}

void Second(int tMinLeft, int tMinRight)
{
    bool leftCloser;
    if (tMinLeft < tMinRight)
    {
        leftCloser = true;
    }
    else
    {
        leftCloser = false;
    }
}

The last unconditional store (leftCloser = false) is substituted into the SELECT which enables further optimization. Specifically it fixes #124713. Still need to investigate regressions.

@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 23, 2026
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 23, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@BoyBaykiller
Copy link
Contributor Author

@dotnet-policy-service agree

* add 'assert(m_cond->OperIsCompare())'
* combine IfConvertCheckFlow + IfConvertCheckStmts into new IfConvertCheck
* get m_mainOper from m_thenOperation instead of flow check
* rework
@BoyBaykiller BoyBaykiller force-pushed the if-conv-unconditional-store-to-else-124713 branch from 208cc34 to cba3e37 Compare March 19, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: Turn conditional move arround bool into setl to save registers

1 participant