Skip to content

JIT: loop inversion doing some questionable profile maintenance #84319

@AndyAyersMS

Description

@AndyAyersMS

From the PerfLabTests.CastingPerf:CheckArrayIsInterfaceNo benchmark, running with TieredPGO, during an OSR recompile:

Note how BB04's profile data gets trashed

****** START compiling PerfLabTests.CastingPerf:CheckArrayIsInterfaceNo():bool:this (MethodHash=a46d9cd6)
Generating code for Windows x64
OPTIONS: Tier-1 compilation
OPTIONS: OSR variant with entry point 0x18
...

*************** Starting PHASE Invert loops
-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight       IBC  lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0004]  1                             1      48701    [???..???)-> BB04 (always)                     i internal IBC 
BB02 [0000]  0                             0.00       1    [000..006)-> BB04 (always)                     i IBC 
BB03 [0001]  1       BB04                100.00 4870143    [006..018)                                     i hascall bwd bwd-target IBC 
BB04 [0002]  3       BB01,BB02,BB03      100    4870144    [018..020)-> BB03 ( cond )                     i bwd bwd-src IBC  osr-entry
BB05 [0003]  1       BB04                  0          0    [020..022)        (return)                     i rare IBC 
-----------------------------------------------------------------------------------------------------------------------------------------

***************  Exception Handling table is empty
=============== No blocks renumbered!

Duplication of loop condition [000010] is performed, because the cost of duplication (17) is less or equal than 136,
   loopIterations = 4870143.000, optInvertTotalInfo.sharedStaticHelperCount >= 0, validProfileWeights = true
New Basic Block BB06 [0005] created.
Setting edge weights for BB02 -> BB06 to [0 .. 1]
Setting edge weights for BB06 -> BB03 to [0 .. 1]
Setting edge weights for BB06 -> BB05 to [0 .. 0]
Redirecting non-loop BB01 -> BB04 to BB01 -> BB06
Setting edge weights for BB01 -> BB06 to [0 .. 1]
Reducing profile weight of BB04 from 4870144 to 4870143
Setting weight of BB04 -> BB03 to 4870142 (iterate loop)
Setting weight of BB04 -> BB05 to 0.9999998 (exit loop)
Setting edge weights for BB04 -> BB03 to [4870142 .. 4870142]
Setting edge weights for BB04 -> BB05 to [0.9999998 .. 0.9999998]
Profile weight of BB02 remains unchanged at 1
Setting weight of BB06 -> BB03 to 0.9999998 (enter loop)
Setting weight of BB06 -> BB05 to 2.053327e-07 (avoid loop)
Setting edge weights for BB06 -> BB03 to [0.9999998 .. 0.9999998]
Setting edge weights for BB06 -> BB05 to [2.053327e-07 .. 2.053327e-07]

Duplicated loop exit block at BB06 for loop (BB03 - BB04)
Estimated code size expansion is 17

------------ BB06 [???..???) -> BB05 (cond), preds={BB01,BB02} succs={BB03,BB05}

***** BB06
STMT00006 ( 0x018[E-] ... ??? )
     ( 11, 17) [000028] ----G------                         *  JTRUE     void  
     (  9, 15) [000029] J---G--N---                         \--*  GE        int   
     (  3,  2) [000030] -----------                            +--*  LCL_VAR   int    V02 loc1         
     (  5, 12) [000031] n---G------                            \--*  IND       int   
     (  3, 10) [000032] H----------                               \--*  CNS_INT(h) long   0x7ffefe7b4cb0 static Fseq[InnerIterationCount]

------------ BB04 [018..020) -> BB03 (cond), preds={BB03} succs={BB05,BB03}

***** BB04
STMT00002 ( 0x018[E-] ... 0x01E )
     ( 11, 17) [000010] ----G------                         *  JTRUE     void  
     (  9, 15) [000009] J---G--N---                         \--*  LT        int   
     (  3,  2) [000006] -----------                            +--*  LCL_VAR   int    V02 loc1         
     (  5, 12) [000008] n---G------                            \--*  IND       int   
     (  3, 10) [000007] H----------                               \--*  CNS_INT(h) long   0x7ffefe7b4cb0 static Fseq[InnerIterationCount]

*************** Finishing PHASE Invert loops
Trees after Invert loops

-----------------------------------------------------------------------------------------------------------------------------------------
BBnum BBid ref try hnd preds           weight       IBC  lp [IL range]     [jump]      [EH region]         [flags]
-----------------------------------------------------------------------------------------------------------------------------------------
BB01 [0004]  1                             1      48701    [???..???)-> BB06 (always)                     i internal IBC 
BB02 [0000]  0                             0.00       1    [000..006)                                     i IBC 
BB06 [0005]  2       BB01,BB02             0.00       1    [???..???)-> BB05 ( cond )                     internal IBC 
BB03 [0001]  2       BB04,BB06           100.00 4870143    [006..018)                                     i hascall bwd bwd-target IBC 
BB04 [0002]  1       BB03                  0.00       1    [018..020)-> BB03 ( cond )                     i bwd bwd-src IBC  osr-entry
BB05 [0003]  2       BB04,BB06             0          0    [020..022)        (return)                     i rare IBC 
-----------------------------------------------------------------------------------------------------------------------------------------

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions