From 76f47b2cd6854ec374268ff52afccaf07e015aa5 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sat, 16 May 2026 00:15:32 +0200 Subject: [PATCH 1/8] fix bug --- src/coreclr/jit/gentree.cpp | 2 +- src/coreclr/jit/importercalls.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 9fa3d6534c50c8..1ca89de1833e61 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -31642,7 +31642,7 @@ NamedIntrinsic GenTreeHWIntrinsic::GetHWIntrinsicIdForCmpOp(Compiler* comp, } else if (isScalar) { - reverseCond ? NI_X86Base_CompareScalarNotLessThanOrEqual : NI_X86Base_CompareScalarGreaterThan; + id = reverseCond ? NI_X86Base_CompareScalarNotLessThanOrEqual : NI_X86Base_CompareScalarGreaterThan; } else { diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 69d7066826707e..bd0ca2c22b472d 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -4777,8 +4777,8 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, // This is now known to be a multi-dimension array with a constant dimension // that is in range; we can expand it as an intrinsic. - impPopStack().val; // Pop the dim and array object; we already have a pointer to them. - impPopStack().val; + impPopStack(); // Pop the dim and array object; we already have a pointer to them. + impPopStack(); // Make sure there are no global effects in the array (such as it being a function // call), so we can mark the generated indirection with GTF_IND_INVARIANT. In the From 834dd452564c9b847e8460e128190a46e263fa65 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sat, 16 May 2026 00:51:17 +0200 Subject: [PATCH 2/8] unused --- src/coreclr/jit/CMakeLists.txt | 10 ++++++++ src/coreclr/jit/emitxarch.cpp | 2 ++ src/coreclr/jit/hwintrinsic.cpp | 40 -------------------------------- src/coreclr/jit/ifconversion.cpp | 2 ++ src/coreclr/jit/lower.cpp | 2 ++ src/coreclr/jit/scev.cpp | 2 ++ 6 files changed, 18 insertions(+), 40 deletions(-) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 3dadf640040780..9b17b596bfc6ae 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -16,6 +16,16 @@ if (MSVC) add_compile_options($<$:/permissive->) endif() +# The JIT enforces -Wunused-function (overriding the repo-wide -Wno-unused-function +# from configurecompiler.cmake) so that dead helpers are caught early. Any helper +# that is only referenced under a target/DEBUG #ifdef must be guarded by the same +# condition. +if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI) + get_directory_property(JIT_COMPILE_OPTIONS COMPILE_OPTIONS) + list(REMOVE_ITEM JIT_COMPILE_OPTIONS -Wno-unused-function) + set_directory_properties(PROPERTIES COMPILE_OPTIONS "${JIT_COMPILE_OPTIONS}") +endif() + function(create_standalone_jit) set(oneValueArgs TARGET OS ARCH) diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 32d20d45385819..0f686bacacab39 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -1586,6 +1586,7 @@ bool emitter::Is4ByteSSEInstruction(instruction ins) const return !UseVEXEncoding() && EncodedBySSE38orSSE3A(ins); } +#ifdef DEBUG //------------------------------------------------------------------------ // isLowSIMDReg: Checks if a register is a register supported by any SIMD encoding // @@ -1602,6 +1603,7 @@ static bool isLowSimdReg(regNumber reg) return (reg >= REG_XMM0) && (reg <= REG_XMM7); #endif } +#endif // DEBUG //------------------------------------------------------------------------ // GetEmbRoundingMode: Get the rounding mode for embedded rounding diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index aed5d2f236e6d3..f9808f6ff44063 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1661,46 +1661,6 @@ static bool impIsTableDrivenHWIntrinsic(NamedIntrinsic intrinsicId, HWIntrinsicC return (category != HW_Category_Special) && !HWIntrinsicInfo::HasSpecialImport(intrinsicId); } -//------------------------------------------------------------------------ -// isSupportedBaseType -// -// Arguments: -// intrinsicId - HW intrinsic id -// baseJitType - Base JIT type of the intrinsic. -// -// Return Value: -// returns true if the baseType is supported for given intrinsic. -// -static bool isSupportedBaseType(NamedIntrinsic intrinsic, CorInfoType baseJitType) -{ - if (baseJitType == CORINFO_TYPE_UNDEF) - { - return false; - } - - var_types baseType = JitType2PreciseVarType(baseJitType); - - // We don't actually check the intrinsic outside of the false case as we expect - // the exposed managed signatures are either generic and support all types - // or they are explicit and support the type indicated. - - if (varTypeIsArithmetic(baseType)) - { - return true; - } - -#ifdef DEBUG - CORINFO_InstructionSet isa = HWIntrinsicInfo::lookupIsa(intrinsic); -#ifdef TARGET_XARCH - assert((isa == InstructionSet_Vector512) || (isa == InstructionSet_Vector256) || (isa == InstructionSet_Vector128)); -#endif // TARGET_XARCH -#ifdef TARGET_ARM64 - assert((isa == InstructionSet_Vector64) || (isa == InstructionSet_Vector128)); -#endif // TARGET_ARM64 -#endif // DEBUG - return false; -} - static bool isSupportedBaseType(NamedIntrinsic intrinsic, var_types baseType) { if (baseType == TYP_UNDEF) diff --git a/src/coreclr/jit/ifconversion.cpp b/src/coreclr/jit/ifconversion.cpp index 51636fe614809b..1f4414f4a93521 100644 --- a/src/coreclr/jit/ifconversion.cpp +++ b/src/coreclr/jit/ifconversion.cpp @@ -742,6 +742,7 @@ GenTree* OptIfConversionDsc::TryOptimizeSelect(GenTreeConditional* select) return nullptr; } +#ifdef TARGET_RISCV64 struct IntConstSelectOper { genTreeOps oper; @@ -794,6 +795,7 @@ static IntConstSelectOper MatchIntConstSelectValues(int64_t trueVal, int64_t fal return {GT_NONE}; } +#endif // TARGET_RISCV64 //----------------------------------------------------------------------------- // TrySelectToCnsOpCond: Try to optimize: diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 0f4075196925d0..00f166e0aff8f9 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -10437,6 +10437,7 @@ static bool IsStoreCoalescingInvariantNode(Compiler* compiler, GenTree* node, bo return node->OperIs(GT_LCL_VAR) && !compiler->lvaVarAddrExposed(node->AsLclVar()->GetLclNum()); } +#if defined(TARGET_XARCH) || defined(TARGET_ARM64) //------------------------------------------------------------------------ // TryGetStoreCoalescingConstantBits: get the raw bits for a constant used by store // coalescing. @@ -10479,6 +10480,7 @@ static bool TryGetStoreCoalescingConstantBits(GenTree* value, uint64_t* bits) return false; } +#endif // TARGET_XARCH || TARGET_ARM64 //------------------------------------------------------------------------ // GetLoadStoreCoalescingData: given a STOREIND/IND node, get the data needed to perform diff --git a/src/coreclr/jit/scev.cpp b/src/coreclr/jit/scev.cpp index 36542081136d6f..b4d83cce55ca84 100644 --- a/src/coreclr/jit/scev.cpp +++ b/src/coreclr/jit/scev.cpp @@ -1469,6 +1469,7 @@ ValueNumPair ScalarEvolutionContext::MaterializeVN(Scev* scev) return Materialize(scev, false, nullptr, &vnp) ? vnp : ValueNumPair(); } +#ifdef DEBUG //------------------------------------------------------------------------ // RelopEvaluationResultString: Convert a RelopEvaluationResult to a string. // @@ -1492,6 +1493,7 @@ static const char* RelopEvaluationResultString(RelopEvaluationResult result) return "n/a"; } } +#endif // DEBUG //------------------------------------------------------------------------ // EvaluateRelop: From e1a44ae66207510acd922545caf3c623ee93ed73 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sat, 16 May 2026 00:54:41 +0200 Subject: [PATCH 3/8] Update importercalls.cpp --- src/coreclr/jit/importercalls.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index bd0ca2c22b472d..62c0b2b267e82e 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -4777,8 +4777,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, // This is now known to be a multi-dimension array with a constant dimension // that is in range; we can expand it as an intrinsic. - impPopStack(); // Pop the dim and array object; we already have a pointer to them. - impPopStack(); + impPopStack(2); // Pop the dim and array object; we already have a pointer to them. // Make sure there are no global effects in the array (such as it being a function // call), so we can mark the generated indirection with GTF_IND_INVARIANT. In the From 3366f0805445c50198f3d77554ff75aefe02d29b Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sat, 16 May 2026 00:58:27 +0200 Subject: [PATCH 4/8] tautological-compare --- src/coreclr/jit/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 9b17b596bfc6ae..c407080ba49444 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -16,13 +16,14 @@ if (MSVC) add_compile_options($<$:/permissive->) endif() -# The JIT enforces -Wunused-function (overriding the repo-wide -Wno-unused-function -# from configurecompiler.cmake) so that dead helpers are caught early. Any helper -# that is only referenced under a target/DEBUG #ifdef must be guarded by the same -# condition. +# The JIT enforces -Wunused-function and -Wtautological-compare (overriding the +# repo-wide -Wno-* counterparts from configurecompiler.cmake) so that dead helpers +# and always-true/always-false comparisons are caught early. Any helper or +# comparison that is only meaningful under a target/DEBUG #ifdef must be guarded +# by the same condition. if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI) get_directory_property(JIT_COMPILE_OPTIONS COMPILE_OPTIONS) - list(REMOVE_ITEM JIT_COMPILE_OPTIONS -Wno-unused-function) + list(REMOVE_ITEM JIT_COMPILE_OPTIONS -Wno-unused-function -Wno-tautological-compare) set_directory_properties(PROPERTIES COMPILE_OPTIONS "${JIT_COMPILE_OPTIONS}") endif() From 8ed0e6d239f32576af831991a5de2454ce9d02bb Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sat, 16 May 2026 01:08:11 +0200 Subject: [PATCH 5/8] more --- src/coreclr/jit/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index c407080ba49444..dd4f3e2f4e4d30 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -16,14 +16,14 @@ if (MSVC) add_compile_options($<$:/permissive->) endif() -# The JIT enforces -Wunused-function and -Wtautological-compare (overriding the -# repo-wide -Wno-* counterparts from configurecompiler.cmake) so that dead helpers -# and always-true/always-false comparisons are caught early. Any helper or -# comparison that is only meaningful under a target/DEBUG #ifdef must be guarded -# by the same condition. +# The JIT enforces -Wunused-function, -Wtautological-compare and -Wunused-value +# (overriding the repo-wide -Wno-* counterparts from configurecompiler.cmake) so +# that dead helpers, always-true/always-false comparisons and discarded +# expressions are caught early. Any helper or comparison that is only meaningful +# under a target/DEBUG #ifdef must be guarded by the same condition. if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI) get_directory_property(JIT_COMPILE_OPTIONS COMPILE_OPTIONS) - list(REMOVE_ITEM JIT_COMPILE_OPTIONS -Wno-unused-function -Wno-tautological-compare) + list(REMOVE_ITEM JIT_COMPILE_OPTIONS -Wno-unused-function -Wno-tautological-compare -Wno-unused-value) set_directory_properties(PROPERTIES COMPILE_OPTIONS "${JIT_COMPILE_OPTIONS}") endif() From 0a8ec94a6510f12e057298965f2784792925677d Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sat, 16 May 2026 19:37:28 +0200 Subject: [PATCH 6/8] Fix JIT warnings-as-errors Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/coreclr/jit/emitriscv64.cpp | 2 +- src/coreclr/jit/gentree.cpp | 6 +++++- src/coreclr/jit/lower.cpp | 13 ++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index babb7122eda7f5..43097293f6557d 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -5768,7 +5768,7 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins } regNumber baseReg = id->idReg2(); - if (baseReg != REG_SP || baseReg != REG_FP) + if ((baseReg != REG_SP) && (baseReg != REG_FP)) result.insLatency += PERFSCORE_LATENCY_1C; // assume non-stack load/stores are more likely to cache-miss result.insThroughput += immediateBuildingCost; diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 1ca89de1833e61..91725d4074e1bc 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -10451,7 +10451,11 @@ bool GenTreeOp::UsesDivideByConstOptimized(Compiler* comp) if (isSignedDivide) { // If the divisor is the minimum representable integer value then the result is either 0 or 1 - if ((divType == TYP_INT && divisorValue == INT_MIN) || (divType == TYP_LONG && divisorValue == INT64_MIN)) + if ((divType == TYP_INT && divisorValue == INT_MIN) +#if defined(TARGET_64BIT) + || (divType == TYP_LONG && divisorValue == INT64_MIN) +#endif + ) { return true; } diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 00f166e0aff8f9..b707498e01adc9 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -8200,8 +8200,11 @@ bool Lowering::TryLowerConstIntUDivOrUMod(GenTreeOp* divMod) { // If the divisor is greater or equal than 2^(N - 1) then the result is 1 // iff the dividend is greater or equal than the divisor. - if (((type == TYP_INT) && (divisorValue > (UINT32_MAX / 2))) || - ((type == TYP_LONG) && (divisorValue > (UINT64_MAX / 2)))) + if (((type == TYP_INT) && (divisorValue > (UINT32_MAX / 2))) +#if defined(TARGET_64BIT) + || ((type == TYP_LONG) && (divisorValue > (UINT64_MAX / 2))) +#endif + ) { divMod->ChangeOper(GT_GE); divMod->SetUnsigned(); @@ -8491,7 +8494,11 @@ bool Lowering::TryLowerConstIntDivOrMod(GenTree* node, GenTree** nextNode) if (isDiv) { - if ((type == TYP_INT && divisorValue == INT_MIN) || (type == TYP_LONG && divisorValue == INT64_MIN)) + if ((type == TYP_INT && divisorValue == INT_MIN) +#if defined(TARGET_64BIT) + || (type == TYP_LONG && divisorValue == INT64_MIN) +#endif + ) { // If the divisor is the minimum representable integer value then we can use a compare, // the result is 1 iff the dividend equals divisor. From a8fa9fc5e05bb05841155f18a039392e3f7fc867 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Mon, 18 May 2026 13:15:18 +0200 Subject: [PATCH 7/8] fix risc-v --- src/coreclr/jit/emitriscv64.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index 43097293f6557d..c82e79956d499b 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -2922,18 +2922,6 @@ static unsigned UpperNBitsOfWordSignExtend(ssize_t word) return UpperNBitsOfWord(word + kSignExtend); } -static unsigned UpperWordOfDoubleWord(ssize_t immediate) -{ - return static_cast(immediate >> 32); -} - -static unsigned LowerWordOfDoubleWord(ssize_t immediate) -{ - static constexpr size_t kWordMask = WordMask(32); - - return static_cast(immediate & kWordMask); -} - template static ssize_t DoubleWordSignExtend(ssize_t doubleWord) { @@ -2943,20 +2931,6 @@ static ssize_t DoubleWordSignExtend(ssize_t doubleWord) return doubleWord + (kLowerSignExtend | kUpperSignExtend); } -template -static ssize_t UpperWordOfDoubleWordSingleSignExtend(ssize_t doubleWord) -{ - static constexpr size_t kUpperSignExtend = static_cast(1) << (31 - UpperMaskSize); - - return UpperWordOfDoubleWord(doubleWord + kUpperSignExtend); -} - -template -static ssize_t UpperWordOfDoubleWordDoubleSignExtend(ssize_t doubleWord) -{ - return UpperWordOfDoubleWord(DoubleWordSignExtend(doubleWord)); -} - /*static*/ unsigned emitter::TrimSignedToImm12(ssize_t imm12) { assert(isValidSimm12(imm12)); From 25f79c246f90110f7cb73e00709d963c3344bcab Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Mon, 18 May 2026 13:27:03 +0200 Subject: [PATCH 8/8] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/coreclr/jit/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index dd4f3e2f4e4d30..cfd3ad77b9f0ee 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -22,9 +22,7 @@ endif() # expressions are caught early. Any helper or comparison that is only meaningful # under a target/DEBUG #ifdef must be guarded by the same condition. if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI) - get_directory_property(JIT_COMPILE_OPTIONS COMPILE_OPTIONS) - list(REMOVE_ITEM JIT_COMPILE_OPTIONS -Wno-unused-function -Wno-tautological-compare -Wno-unused-value) - set_directory_properties(PROPERTIES COMPILE_OPTIONS "${JIT_COMPILE_OPTIONS}") + add_compile_options(-Wunused-function -Wtautological-compare -Wunused-value) endif() function(create_standalone_jit)