Skip to content

Commit b85dd69

Browse files
authored
JIT: Avoid byref strength reductions in loops with suspension points (#115605)
Reducing to a byref type (e.g. when iterating through an array) in a loop with suspension points is not valid, since the new byref IV will be live across the suspension point. In those cases instead strength reduce to the index.
1 parent 42a0b42 commit b85dd69

File tree

4 files changed

+210
-128
lines changed

4 files changed

+210
-128
lines changed

src/coreclr/jit/compiler.h

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,22 @@ inline var_types genActualType(T value);
7272
* Forward declarations
7373
*/
7474

75-
struct InfoHdr; // defined in GCInfo.h
76-
struct escapeMapping_t; // defined in fgdiagnostic.cpp
77-
class emitter; // defined in emit.h
78-
struct ShadowParamVarInfo; // defined in GSChecks.cpp
79-
struct InitVarDscInfo; // defined in registerargconvention.h
80-
class FgStack; // defined in fgbasic.cpp
81-
class Instrumentor; // defined in fgprofile.cpp
82-
class SpanningTreeVisitor; // defined in fgprofile.cpp
83-
class CSE_DataFlow; // defined in optcse.cpp
84-
struct CSEdsc; // defined in optcse.h
85-
class CSE_HeuristicCommon; // defined in optcse.h
86-
class OptBoolsDsc; // defined in optimizer.cpp
87-
struct JumpThreadInfo; // defined in redundantbranchopts.cpp
88-
class ProfileSynthesis; // defined in profilesynthesis.h
89-
class LoopLocalOccurrences; // defined in inductionvariableopts.cpp
90-
class RangeCheck; // defined in rangecheck.h
75+
struct InfoHdr; // defined in GCInfo.h
76+
struct escapeMapping_t; // defined in fgdiagnostic.cpp
77+
class emitter; // defined in emit.h
78+
struct ShadowParamVarInfo; // defined in GSChecks.cpp
79+
struct InitVarDscInfo; // defined in registerargconvention.h
80+
class FgStack; // defined in fgbasic.cpp
81+
class Instrumentor; // defined in fgprofile.cpp
82+
class SpanningTreeVisitor; // defined in fgprofile.cpp
83+
class CSE_DataFlow; // defined in optcse.cpp
84+
struct CSEdsc; // defined in optcse.h
85+
class CSE_HeuristicCommon; // defined in optcse.h
86+
class OptBoolsDsc; // defined in optimizer.cpp
87+
struct JumpThreadInfo; // defined in redundantbranchopts.cpp
88+
class ProfileSynthesis; // defined in profilesynthesis.h
89+
class PerLoopInfo; // defined in inductionvariableopts.cpp
90+
class RangeCheck; // defined in rangecheck.h
9191
#ifdef DEBUG
9292
struct IndentStack;
9393
#endif
@@ -7654,33 +7654,30 @@ class Compiler
76547654
void optVisitBoundingExitingCondBlocks(FlowGraphNaturalLoop* loop, TFunctor func);
76557655
bool optMakeLoopDownwardsCounted(ScalarEvolutionContext& scevContext,
76567656
FlowGraphNaturalLoop* loop,
7657-
LoopLocalOccurrences* loopLocals);
7657+
PerLoopInfo* loopLocals);
76587658
bool optMakeExitTestDownwardsCounted(ScalarEvolutionContext& scevContext,
76597659
FlowGraphNaturalLoop* loop,
76607660
BasicBlock* exiting,
7661-
LoopLocalOccurrences* loopLocals);
7661+
PerLoopInfo* loopLocals);
76627662
bool optCanAndShouldChangeExitTest(GenTree* cond, bool dump);
7663-
bool optLocalHasNonLoopUses(unsigned lclNum, FlowGraphNaturalLoop* loop, LoopLocalOccurrences* loopLocals);
7663+
bool optLocalHasNonLoopUses(unsigned lclNum, FlowGraphNaturalLoop* loop, PerLoopInfo* loopLocals);
76647664
bool optLocalIsLiveIntoBlock(unsigned lclNum, BasicBlock* block);
76657665

7666-
bool optWidenIVs(ScalarEvolutionContext& scevContext, FlowGraphNaturalLoop* loop, LoopLocalOccurrences* loopLocals);
7667-
bool optWidenPrimaryIV(FlowGraphNaturalLoop* loop,
7668-
unsigned lclNum,
7669-
ScevAddRec* addRec,
7670-
LoopLocalOccurrences* loopLocals);
7666+
bool optWidenIVs(ScalarEvolutionContext& scevContext, FlowGraphNaturalLoop* loop, PerLoopInfo* loopLocals);
7667+
bool optWidenPrimaryIV(FlowGraphNaturalLoop* loop, unsigned lclNum, ScevAddRec* addRec, PerLoopInfo* loopLocals);
76717668

76727669
bool optCanSinkWidenedIV(unsigned lclNum, FlowGraphNaturalLoop* loop);
76737670
bool optIsIVWideningProfitable(unsigned lclNum,
76747671
BasicBlock* initBlock,
76757672
bool initedToConstant,
76767673
FlowGraphNaturalLoop* loop,
7677-
LoopLocalOccurrences* loopLocals);
7674+
PerLoopInfo* loopLocals);
76787675
void optBestEffortReplaceNarrowIVUses(
76797676
unsigned lclNum, unsigned ssaNum, unsigned newLclNum, BasicBlock* block, Statement* firstStmt);
76807677
void optReplaceWidenedIV(unsigned lclNum, unsigned ssaNum, unsigned newLclNum, Statement* stmt);
76817678
void optSinkWidenedIV(unsigned lclNum, unsigned newLclNum, FlowGraphNaturalLoop* loop);
76827679

7683-
bool optRemoveUnusedIVs(FlowGraphNaturalLoop* loop, LoopLocalOccurrences* loopLocals);
7680+
bool optRemoveUnusedIVs(FlowGraphNaturalLoop* loop, PerLoopInfo* loopLocals);
76847681
bool optIsUpdateOfIVWithoutSideEffects(GenTree* tree, unsigned lclNum);
76857682

76867683
// Redundant branch opts

0 commit comments

Comments
 (0)