Skip to content
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

Update il range in optOptimizeBoolsUpdateTrees #74657

Merged
merged 1 commit into from
Sep 25, 2022
Merged

Conversation

En3Tho
Copy link
Contributor

@En3Tho En3Tho commented Aug 26, 2022

Possible fix for #49471

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 26, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Aug 26, 2022
@ghost
Copy link

ghost commented Aug 26, 2022

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

Issue Details

Possible fix for #49471

So far I wasn't been able to repro this BasicBlock optimization. So leaving this as draft for now (and hope tests will catch something)

Author: En3Tho
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@En3Tho
Copy link
Contributor Author

En3Tho commented Aug 31, 2022

For this kind of method IL range seems to be updated correctly

static int TestBasicBlocks(int x, int y)
    {
        if (x == 0 && y == 0)
        {
            return 0;
        }

        return 2;
    }
*************** Finishing PHASE Find loops
Trees after Find loops

-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight    lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0000]  1                             1       [000..003)-> BB04 ( cond )                     i 
BB02 [0001]  1       BB01                  0.50    [003..006)-> BB04 ( cond )                     i 
BB03 [0002]  1       BB02                  0.50    [006..008)        (return)                     i 
BB04 [0003]  2       BB01,BB02             0.50    [008..00A)        (return)                     i 
-----------------------------------------------------------------------------------------------------------------------------------------

=>

Before:

*************** Finishing PHASE Optimize bools
Trees after Optimize bools

-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight    lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0000]  1                             1       [000..003)-> BB04 ( cond )                     i 
BB03 [0002]  1       BB01                  0.50    [006..008)        (return)                     i 
BB04 [0003]  1       BB01                  0.50    [008..00A)        (return)                     i 
-----------------------------------------------------------------------------------------------------------------------------------------

After:

*************** Finishing PHASE Optimize bools
Trees after Optimize bools

-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight    lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0000]  1                             1       [000..006)-> BB04 ( cond )                     i 
BB03 [0002]  1       BB01                  0.50    [006..008)        (return)                     i 
BB04 [0003]  1       BB01                  0.50    [008..00A)        (return)                     i 
-----------------------------------------------------------------------------------------------------------------------------------------

@En3Tho En3Tho marked this pull request as ready for review August 31, 2022 16:57
@En3Tho
Copy link
Contributor Author

En3Tho commented Aug 31, 2022

Should an assert be added somewhere after OptimizeBools?
To check that basic blocks ranges are correctly updated

@En3Tho En3Tho changed the title [draft] Update il range in optOptimizeBoolsUpdateTrees Update il range in optOptimizeBoolsUpdateTrees Sep 1, 2022
@JulieLeeMSFT JulieLeeMSFT added this to the 8.0.0 milestone Sep 1, 2022
@JulieLeeMSFT
Copy link
Member

Thanks @En3Tho for the PR. We are now busy with finishing up .NET 7. @EgorBo, Please review this community contribution.

@En3Tho
Copy link
Contributor Author

En3Tho commented Sep 23, 2022

Can someone review this please?

@EgorBo
Copy link
Member

EgorBo commented Sep 23, 2022

Sorry for the long delay, thanks for the contribution! Looks good to me, could you please check what it returns for:

static int TestBasicBlocks(int x, int y) => x == 0 && y == 0;

(the case with RETURN)

@En3Tho
Copy link
Contributor Author

En3Tho commented Sep 23, 2022

@EgorBo Thanks! I changed you example to

public static bool TestBasicBlocks2(int x, int y) => x == 0 && y == 0;

I hope you meant bool, not int.

With PR:

*************** Finishing PHASE Optimize bools
Trees after Optimize bools

-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight    lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0000]  1                             1       [000..00A)        (return)                     i 
-----------------------------------------------------------------------------------------------------------------------------------------

Without:

*************** Finishing PHASE Optimize bools
Trees after Optimize bools

-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight    lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0000]  1                             1       [000..003)        (return)                     i 
-----------------------------------------------------------------------------------------------------------------------------------------

It seems to be correctly updated to 000..00A

For example this is how it looks few phases before:

*************** Finishing PHASE Find loops
Trees after Find loops

-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight    lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0000]  1                             1       [000..003)-> BB03 ( cond )                     i 
BB02 [0001]  1       BB01                  0.50    [003..008)        (return)                     i 
BB03 [0002]  1       BB01                  0.50    [008..00A)        (return)                     i 
-----------------------------------------------------------------------------------------------------------------------------------------

@EgorBo
Copy link
Member

EgorBo commented Sep 25, 2022

Thanks for your contribution!

@EgorBo EgorBo merged commit e26f6b0 into dotnet:main Sep 25, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

3 participants