Skip to content
Merged
9 changes: 9 additions & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ 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)
add_compile_options(-Wunused-function -Wtautological-compare -Wunused-value)
endif()

function(create_standalone_jit)

set(oneValueArgs TARGET OS ARCH)
Expand Down
28 changes: 1 addition & 27 deletions src/coreclr/jit/emitriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2922,18 +2922,6 @@ static unsigned UpperNBitsOfWordSignExtend(ssize_t word)
return UpperNBitsOfWord<MaskSize>(word + kSignExtend);
}

static unsigned UpperWordOfDoubleWord(ssize_t immediate)
{
return static_cast<unsigned>(immediate >> 32);
}

static unsigned LowerWordOfDoubleWord(ssize_t immediate)
{
static constexpr size_t kWordMask = WordMask(32);

return static_cast<unsigned>(immediate & kWordMask);
}

template <uint8_t UpperMaskSize, uint8_t LowerMaskSize>
static ssize_t DoubleWordSignExtend(ssize_t doubleWord)
{
Expand All @@ -2943,20 +2931,6 @@ static ssize_t DoubleWordSignExtend(ssize_t doubleWord)
return doubleWord + (kLowerSignExtend | kUpperSignExtend);
}

template <uint8_t UpperMaskSize>
static ssize_t UpperWordOfDoubleWordSingleSignExtend(ssize_t doubleWord)
{
static constexpr size_t kUpperSignExtend = static_cast<size_t>(1) << (31 - UpperMaskSize);

return UpperWordOfDoubleWord(doubleWord + kUpperSignExtend);
}

template <uint8_t UpperMaskSize, uint8_t LowerMaskSize>
static ssize_t UpperWordOfDoubleWordDoubleSignExtend(ssize_t doubleWord)
{
return UpperWordOfDoubleWord(DoubleWordSignExtend<UpperMaskSize, LowerMaskSize>(doubleWord));
}

/*static*/ unsigned emitter::TrimSignedToImm12(ssize_t imm12)
{
assert(isValidSimm12(imm12));
Expand Down Expand Up @@ -5768,7 +5742,7 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins
}

regNumber baseReg = id->idReg2();
if (baseReg != REG_SP || baseReg != REG_FP)
if ((baseReg != REG_SP) && (baseReg != REG_FP))
Comment thread
EgorBo marked this conversation as resolved.
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 @@ -1665,6 +1665,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
Comment thread
EgorBo marked this conversation as resolved.
//
Expand All @@ -1681,6 +1682,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 @@ -10467,7 +10467,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 @@ -32026,7 +32030,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 @@ -4776,8 +4776,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 @@ -8157,8 +8157,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
)
Comment thread
EgorBo marked this conversation as resolved.
Comment thread
EgorBo marked this conversation as resolved.
{
divMod->ChangeOper(GT_GE);
divMod->SetUnsigned();
Expand Down Expand Up @@ -8448,7 +8451,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 @@ -10400,6 +10407,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 @@ -10442,6 +10450,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