Skip to content

Commit 282891d

Browse files
Make JitOptRepeat available in Release builds (#100494)
Also, fix a problem in superpmi.py asmdiffs for Release builds where we got a divide by zero because release builds don't have PerfScore.
1 parent 4039b45 commit 282891d

File tree

5 files changed

+23
-30
lines changed

5 files changed

+23
-30
lines changed

src/coreclr/jit/compiler.cpp

+9-13
Original file line numberDiff line numberDiff line change
@@ -2902,10 +2902,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
29022902
opts.disAlignment = false;
29032903
opts.disCodeBytes = false;
29042904

2905-
#ifdef OPT_CONFIG
2906-
opts.optRepeat = false;
2907-
#endif // OPT_CONFIG
2908-
2905+
opts.optRepeat = false;
29092906
opts.optRepeatIteration = 0;
29102907
opts.optRepeatCount = 1;
29112908
opts.optRepeatActive = false;
@@ -3084,6 +3081,13 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
30843081
{
30853082
opts.disAsm = true;
30863083
}
3084+
3085+
if ((JitConfig.JitEnableOptRepeat() != 0) &&
3086+
(JitConfig.JitOptRepeat().contains(info.compMethodHnd, info.compClassHnd, &info.compMethodInfo->args)))
3087+
{
3088+
opts.optRepeat = true;
3089+
opts.optRepeatCount = JitConfig.JitOptRepeatCount();
3090+
}
30873091
#endif // !DEBUG
30883092

30893093
#ifndef DEBUG
@@ -3109,8 +3113,6 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
31093113
}
31103114
}
31113115

3112-
#ifdef OPT_CONFIG
3113-
31143116
if (opts.optRepeat)
31153117
{
31163118
// Defer printing this until now, after the "START" line printed above.
@@ -3132,7 +3134,6 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
31323134
JITDUMP("\n*************** JitOptRepeat enabled by JitOptRepeatRange; repetition count: %d\n\n",
31333135
opts.optRepeatCount);
31343136
}
3135-
#endif // DEBUG
31363137

31373138
if (!opts.optRepeat && compStressCompile(STRESS_OPT_REPEAT, 10))
31383139
{
@@ -3146,10 +3147,9 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
31463147

31473148
JITDUMP("\n*************** JitOptRepeat for stress; repetition count: %d\n\n", opts.optRepeatCount);
31483149
}
3150+
#endif // DEBUG
31493151
}
31503152

3151-
#endif // OPT_CONFIG
3152-
31533153
#ifdef DEBUG
31543154
assert(!codeGen->isGCTypeFixed());
31553155
opts.compGcChecks = (JitConfig.JitGCChecks() != 0) || compStressCompile(STRESS_GENERIC_VARN, 5);
@@ -5012,12 +5012,10 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
50125012
doVNBasedDeadStoreRemoval = doValueNum && (JitConfig.JitDoVNBasedDeadStoreRemoval() != 0);
50135013
#endif // defined(OPT_CONFIG)
50145014

5015-
#ifdef DEBUG
50165015
if (opts.optRepeat)
50175016
{
50185017
opts.optRepeatActive = true;
50195018
}
5020-
#endif // DEBUG
50215019

50225020
while (++opts.optRepeatIteration <= opts.optRepeatCount)
50235021
{
@@ -5166,12 +5164,10 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
51665164
#endif // DEBUG
51675165
}
51685166

5169-
#ifdef DEBUG
51705167
if (opts.optRepeat)
51715168
{
51725169
opts.optRepeatActive = false;
51735170
}
5174-
#endif // DEBUG
51755171
}
51765172

51775173
optLoopsCanonical = false;

src/coreclr/jit/compiler.h

+6-9
Original file line numberDiff line numberDiff line change
@@ -9874,15 +9874,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
98749874
bool genFPopt; // Can we do frame-pointer-omission optimization?
98759875
bool altJit; // True if we are an altjit and are compiling this method
98769876

9877-
#ifdef OPT_CONFIG
9878-
bool optRepeat; // Repeat optimizer phases k times
9879-
#endif
9880-
9881-
int optRepeatIteration; // The current optRepeat iteration: from 0 to optRepeatCount. optRepeatCount can be
9882-
// zero, in which case no optimizations in the set of repeated optimizations are
9883-
// performed. optRepeatIteration will only be zero if optRepeatCount is zero.
9884-
int optRepeatCount; // How many times to repeat. By default, comes from JitConfig.JitOptRepeatCount().
9885-
bool optRepeatActive; // `true` if we are in the range of phases being repeated.
9877+
bool optRepeat; // Repeat optimizer phases k times
9878+
int optRepeatIteration; // The current optRepeat iteration: from 0 to optRepeatCount. optRepeatCount can be
9879+
// zero, in which case no optimizations in the set of repeated optimizations are
9880+
// performed. optRepeatIteration will only be zero if optRepeatCount is zero.
9881+
int optRepeatCount; // How many times to repeat. By default, comes from JitConfig.JitOptRepeatCount().
9882+
bool optRepeatActive; // `true` if we are in the range of phases being repeated.
98869883

98879884
bool disAsm; // Display native code as it is generated
98889885
bool disTesting; // Display BEGIN METHOD/END METHOD anchors for disasm testing

src/coreclr/jit/jitconfigvalues.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,16 @@ CONFIG_STRING(JitEnableInductionVariableOptsRange, W("JitEnableInductionVariable
521521
CONFIG_INTEGER(JitDoSsa, W("JitDoSsa"), 1) // Perform Static Single Assignment (SSA) numbering on the variables
522522
CONFIG_INTEGER(JitDoValueNumber, W("JitDoValueNumber"), 1) // Perform value numbering on method expressions
523523

524-
CONFIG_INTEGER(JitEnableOptRepeat, W("JitEnableOptRepeat"), 1) // If zero, do not allow JitOptRepeat
525-
CONFIG_METHODSET(JitOptRepeat, W("JitOptRepeat")) // Runs optimizer multiple times on specified methods
526-
CONFIG_INTEGER(JitOptRepeatCount, W("JitOptRepeatCount"), 2) // Number of times to repeat opts when repeating
527-
CONFIG_STRING(JitOptRepeatRange, W("JitOptRepeatRange")) // Enable JitOptRepeat based on method hash range
524+
CONFIG_STRING(JitOptRepeatRange, W("JitOptRepeatRange")) // Enable JitOptRepeat based on method hash range
528525

529526
CONFIG_INTEGER(JitDoIfConversion, W("JitDoIfConversion"), 1) // Perform If conversion
530527

531528
#endif // defined(OPT_CONFIG)
532529

530+
CONFIG_INTEGER(JitEnableOptRepeat, W("JitEnableOptRepeat"), 1) // If zero, do not allow JitOptRepeat
531+
CONFIG_METHODSET(JitOptRepeat, W("JitOptRepeat")) // Runs optimizer multiple times on specified methods
532+
CONFIG_INTEGER(JitOptRepeatCount, W("JitOptRepeatCount"), 2) // Number of times to repeat opts when repeating
533+
533534
// Max # of MapSelect's considered for a particular top-level invocation.
534535
CONFIG_INTEGER(JitVNMapSelBudget, W("JitVNMapSelBudget"), DEFAULT_MAP_SELECT_BUDGET)
535536

src/coreclr/jit/optimizer.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,12 @@ bool Compiler::optExtractInitTestIncr(
503503
if (initStmt->GetRootNode()->OperIs(GT_JTRUE))
504504
{
505505
bool doGetPrev = true;
506-
#ifdef OPT_CONFIG
507506
if (opts.optRepeat)
508507
{
509508
// Previous optimization passes may have inserted compiler-generated
510509
// statements other than duplicated loop conditions.
511510
doGetPrev = (initStmt->GetPrevStmt() != nullptr);
512511
}
513-
#endif // OPT_CONFIG
514512
if (doGetPrev)
515513
{
516514
initStmt = initStmt->GetPrevStmt();

src/coreclr/scripts/superpmi.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2345,8 +2345,9 @@ def create_exception():
23452345
diff_perfscore = diff_metrics["Overall"]["Diffed PerfScore"]
23462346
logging.info("Total PerfScore of base: {}".format(base_perfscore))
23472347
logging.info("Total PerfScore of diff: {}".format(diff_perfscore))
2348-
delta_perfscore = diff_perfscore - base_perfscore
2349-
logging.info("Total PerfScore of delta: {} ({:.2%} of base)".format(delta_perfscore, delta_perfscore / base_perfscore))
2348+
if base_perfscore != 0:
2349+
delta_perfscore = diff_perfscore - base_perfscore
2350+
logging.info("Total PerfScore of delta: {} ({:.2%} of base)".format(delta_perfscore, delta_perfscore / base_perfscore))
23502351
logging.info("")
23512352

23522353
relative_perfscore_geomean = diff_metrics["Overall"]["Relative PerfScore Geomean"]

0 commit comments

Comments
 (0)