Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ if (MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/permissive->)
endif()

# 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 -Wno-unused-value)
set_directory_properties(PROPERTIES COMPILE_OPTIONS "${JIT_COMPILE_OPTIONS}")
endif()

function(create_standalone_jit)

set(oneValueArgs TARGET OS ARCH)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -31642,7 +31646,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
{
Expand Down
40 changes: 0 additions & 40 deletions src/coreclr/jit/hwintrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/ifconversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ GenTree* OptIfConversionDsc::TryOptimizeSelect(GenTreeConditional* select)
return nullptr;
}

#ifdef TARGET_RISCV64
struct IntConstSelectOper
{
genTreeOps oper;
Expand Down Expand Up @@ -794,6 +795,7 @@ static IntConstSelectOper MatchIntConstSelectValues(int64_t trueVal, int64_t fal

return {GT_NONE};
}
#endif // TARGET_RISCV64

//-----------------------------------------------------------------------------
// TrySelectToCnsOpCond: Try to optimize:
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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().val; // Pop the dim and array object; we already have a pointer to them.
impPopStack().val;
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
Expand Down
15 changes: 12 additions & 3 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -10437,6 +10444,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.
Expand Down Expand Up @@ -10479,6 +10487,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
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/scev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand All @@ -1492,6 +1493,7 @@ static const char* RelopEvaluationResultString(RelopEvaluationResult result)
return "n/a";
}
}
#endif // DEBUG

//------------------------------------------------------------------------
// EvaluateRelop:
Expand Down
Loading