Skip to content

Commit 5356857

Browse files
authored
Add simple Else conditions to If Conversion (#77728)
* Add simple Else conditions to If Conversion For example: if (x < 7) { a = 5; } else { a = 9; } a = (cond) ? b : c; The else condition must write to the same variable as the then statement. * Move phase and stop updating ssa * Wrap JitConfig access * Add GT_RETURN else cases * Add test cases with verification checks * Ensure single only operation condition checks are used * Remove empty line * Use DOTNET_ instead of COMPlus_ * Move JitDoIfConversion check * Move if conversion into it's own file * Always invert condition * Rename IfConvertMergeBlocks * Use gtGetOp1() * Expand tests * Add operation type assert * Allow nested SELECT nodes * Fix condition directions
1 parent becfc23 commit 5356857

5 files changed

Lines changed: 998 additions & 373 deletions

File tree

src/coreclr/jit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ set( JIT_SOURCES
124124
hashbv.cpp
125125
hwintrinsic.cpp
126126
hostallocator.cpp
127+
ifconversion.cpp
127128
indirectcalltransformer.cpp
128129
importercalls.cpp
129130
importer.cpp

src/coreclr/jit/compiler.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4755,7 +4755,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
47554755
bool doCse = true;
47564756
bool doAssertionProp = true;
47574757
bool doRangeAnalysis = true;
4758-
bool doIfConversion = true;
47594758
bool doVNBasedDeadStoreRemoval = true;
47604759
int iterations = 1;
47614760

@@ -4769,7 +4768,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
47694768
doCse = doValueNum;
47704769
doAssertionProp = doValueNum && (JitConfig.JitDoAssertionProp() != 0);
47714770
doRangeAnalysis = doAssertionProp && (JitConfig.JitDoRangeAnalysis() != 0);
4772-
doIfConversion = doIfConversion && (JitConfig.JitDoIfConversion() != 0);
47734771
doVNBasedDeadStoreRemoval = doValueNum && (JitConfig.JitDoVNBasedDeadStoreRemoval() != 0);
47744772

47754773
if (opts.optRepeat)
@@ -4852,13 +4850,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
48524850
DoPhase(this, PHASE_ASSERTION_PROP_MAIN, &Compiler::optAssertionPropMain);
48534851
}
48544852

4855-
if (doIfConversion)
4856-
{
4857-
// If conversion
4858-
//
4859-
DoPhase(this, PHASE_IF_CONVERSION, &Compiler::optIfConversion);
4860-
}
4861-
48624853
if (doRangeAnalysis)
48634854
{
48644855
// Bounds check elimination via range analysis
@@ -4910,6 +4901,10 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
49104901
//
49114902
DoPhase(this, PHASE_OPTIMIZE_BOOLS, &Compiler::optOptimizeBools);
49124903

4904+
// If conversion
4905+
//
4906+
DoPhase(this, PHASE_IF_CONVERSION, &Compiler::optIfConversion);
4907+
49134908
// Optimize block order
49144909
//
49154910
DoPhase(this, PHASE_OPTIMIZE_LAYOUT, &Compiler::optOptimizeLayout);

0 commit comments

Comments
 (0)