diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index d535dfb1454570..d4477e3ef7b53e 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -1195,15 +1195,9 @@ bool CodeGen::genCreateAddrMode(GenTree* addr, /* Check for an addition of a constant */ - if (op2->IsIntCnsFitsInI32() && (op2->gtType != TYP_REF) && FitsIn(cns + op2->AsIntConCommon()->IconValue())) + if (op2->IsIntCnsFitsInI32() && op2->AsIntConCommon()->ImmedValCanBeFolded(compiler, addr->OperGet()) && + (op2->gtType != TYP_REF) && FitsIn(cns + op2->AsIntConCommon()->IconValue())) { - // We should not be building address modes out of non-foldable constants - if (!op2->AsIntConCommon()->ImmedValCanBeFolded(compiler, addr->OperGet())) - { - assert(compiler->opts.compReloc); - return false; - } - /* We're adding a constant */ cns += op2->AsIntConCommon()->IconValue(); diff --git a/src/coreclr/jit/likelyclass.cpp b/src/coreclr/jit/likelyclass.cpp index e181a2e9a135ab..b3b86804f55093 100644 --- a/src/coreclr/jit/likelyclass.cpp +++ b/src/coreclr/jit/likelyclass.cpp @@ -38,7 +38,10 @@ struct LikelyClassMethodHistogramEntry // struct LikelyClassMethodHistogram { - LikelyClassMethodHistogram(INT_PTR* histogramEntries, unsigned entryCount); + LikelyClassMethodHistogram(INT_PTR* histogramEntries, unsigned entryCount, bool int32Data = false); + + template + void LikelyClassMethodHistogramInner(ElemType* histogramEntries, unsigned entryCount); // Sum of counts from all entries in the histogram. This includes "unknown" entries which are not captured in // m_histogram @@ -61,8 +64,22 @@ struct LikelyClassMethodHistogram // Arguments: // histogramEntries - pointer to the table portion of a ClassProfile* object (see corjit.h) // entryCount - number of entries in the table to examine +// int32Data - true if table entries are 32 bits // -LikelyClassMethodHistogram::LikelyClassMethodHistogram(INT_PTR* histogramEntries, unsigned entryCount) +LikelyClassMethodHistogram::LikelyClassMethodHistogram(INT_PTR* histogramEntries, unsigned entryCount, bool int32Data) +{ + if (int32Data) + { + LikelyClassMethodHistogramInner((int*)histogramEntries, entryCount); + } + else + { + LikelyClassMethodHistogramInner(histogramEntries, entryCount); + } +} + +template +void LikelyClassMethodHistogram::LikelyClassMethodHistogramInner(ElemType* histogramEntries, unsigned entryCount) { m_unknownHandles = 0; m_totalCount = 0; @@ -76,8 +93,7 @@ LikelyClassMethodHistogram::LikelyClassMethodHistogram(INT_PTR* histogramEntries } m_totalCount++; - - INT_PTR currentEntry = histogramEntries[k]; + INT_PTR currentEntry = (INT_PTR)histogramEntries[k]; bool found = false; unsigned h = 0; @@ -385,15 +401,18 @@ extern "C" DLLEXPORT UINT32 WINAPI getLikelyValues(LikelyValueRecord* continue; // We currently re-use existing infrastructure for type handles for simplicity. - - const bool isHistogramCount = - (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogramIntCount) || + // + const bool isIntHistogramCount = + (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogramIntCount); + const bool isLongHistogramCount = (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogramLongCount); + const bool isHistogramCount = isIntHistogramCount || isLongHistogramCount; if (isHistogramCount && (schema[i].Count == 1) && ((i + 1) < countSchemaItems) && (schema[i + 1].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogram)) { - LikelyClassMethodHistogram h((INT_PTR*)(pInstrumentationData + schema[i + 1].Offset), schema[i + 1].Count); + LikelyClassMethodHistogram h((INT_PTR*)(pInstrumentationData + schema[i + 1].Offset), schema[i + 1].Count, + isIntHistogramCount); LikelyClassMethodHistogramEntry sortedEntries[HISTOGRAM_MAX_SIZE_COUNT]; if (h.countHistogramElements == 0) diff --git a/src/coreclr/jit/scev.cpp b/src/coreclr/jit/scev.cpp index 94e75dc22a35af..e1140e48660cd5 100644 --- a/src/coreclr/jit/scev.cpp +++ b/src/coreclr/jit/scev.cpp @@ -60,6 +60,19 @@ #include "jitpch.h" +ScevConstant::ScevConstant(var_types type, int64_t value) + : Scev(ScevOper::Constant, type) +{ + if (genTypeSize(type) == 4) + { + Value = (int32_t)value; + } + else + { + Value = value; + } +} + //------------------------------------------------------------------------ // GetConstantValue: If this SSA use refers to a constant, then fetch that // constant. diff --git a/src/coreclr/jit/scev.h b/src/coreclr/jit/scev.h index 6d55ccc80227ca..46036daaf25cf0 100644 --- a/src/coreclr/jit/scev.h +++ b/src/coreclr/jit/scev.h @@ -82,11 +82,7 @@ struct Scev struct ScevConstant : Scev { - ScevConstant(var_types type, int64_t value) - : Scev(ScevOper::Constant, type) - , Value(value) - { - } + ScevConstant(var_types type, int64_t value); int64_t Value; };