diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 787d49ab5749e8..cfddb43f762d73 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -12949,6 +12949,12 @@ GenTree* Compiler::gtFoldExprConditional(GenTree* tree) DISPTREE(replacement); JITDUMP("\n"); + // If we bashed to a compare, try to fold that. + if (replacement->OperIsCompare()) + { + return gtFoldExprCompare(replacement); + } + return replacement; } diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index fb03e3d24d5463..7b244e1ada1a7d 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -4499,17 +4499,12 @@ bool Compiler::optIfConvert(BasicBlock* block) // Arm only for now. #ifdef TARGET_ARM64 - // Don't optimise the block if it is inside a loop. + // Don't optimise the block if it is inside a loop // When inside a loop, branches are quicker than selects. - if (fgHasLoops) + // Detect via the block weight as that will be high when inside a loop. + if (block->getBBWeight(this) > BB_UNITY_WEIGHT) { - for (unsigned loopNum = 0; loopNum < optLoopCount; loopNum++) - { - if (optLoopTable[loopNum].lpContains(block)) - { - return false; - } - } + return false; } // Does the block end by branching via a JTRUE after a compare?