Skip to content

Commit 4d7aaec

Browse files
committed
Moved logic to separate functions (#70145)
1 parent 5548ead commit 4d7aaec

File tree

3 files changed

+232
-180
lines changed

3 files changed

+232
-180
lines changed

src/coreclr/jit/assertionprop.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,50 @@ bool IntegralRange::Contains(int64_t value) const
6868
return SymbolicToRealMap[static_cast<int32_t>(value)];
6969
}
7070

71+
//------------------------------------------------------------------------
72+
// GetUpperBound: Get the largest possible value "type" can represent
73+
//
74+
// Arguments:
75+
// node - the node, of an integral type, in question
76+
// type - the integral type in question
77+
// compiler - the Compiler, used to retrieve additional info
78+
//
79+
// Return Value:
80+
// the largest possible value "type" can represent.
81+
//
82+
/* static */ size_t IntegralRange::GetUpperBound(GenTree* node, var_types type, Compiler* compiler)
83+
{
84+
IntegralRange valRange = IntegralRange::ForNode(node, compiler);
85+
#if defined(HOST_X86) || defined(HOST_ARM)
86+
return (int32_t)IntegralRange::SymbolicToRealValue(valRange.UpperBoundForType(type));
87+
#else
88+
return IntegralRange::SymbolicToRealValue(valRange.UpperBoundForType(type));
89+
#endif
90+
91+
}
92+
93+
//------------------------------------------------------------------------
94+
// GetUpperBound: Get the smallest possible value "type" can represent
95+
//
96+
// Arguments:
97+
// node - the node, of an integral type, in question
98+
// type - the integral type in question
99+
// compiler - the Compiler, used to retrieve additional info
100+
//
101+
// Return Value:
102+
// the smallest possible value "type" can represent.
103+
//
104+
/* static */ size_t IntegralRange::GetLowerBound(GenTree* node, var_types type, Compiler* compiler)
105+
{
106+
IntegralRange valRange = IntegralRange::ForNode(node, compiler);
107+
#if defined(HOST_X86) || defined(HOST_ARM)
108+
return (int32_t)IntegralRange::SymbolicToRealValue(valRange.LowerBoundForType(type));
109+
#else
110+
return IntegralRange::SymbolicToRealValue(valRange.LowerBoundForType(type));
111+
112+
#endif
113+
}
114+
71115
//------------------------------------------------------------------------
72116
// LowerBoundForType: Get the symbolic lower bound for a type.
73117
//

src/coreclr/jit/compiler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,8 @@ class IntegralRange
12601260
}
12611261

12621262
static int64_t SymbolicToRealValue(SymbolicIntegerValue value);
1263+
static size_t GetUpperBound(GenTree* node, var_types type, Compiler* compiler);
1264+
static size_t GetLowerBound(GenTree* node, var_types type, Compiler* compiler);
12631265
static SymbolicIntegerValue LowerBoundForType(var_types type);
12641266
static SymbolicIntegerValue UpperBoundForType(var_types type);
12651267

@@ -5690,6 +5692,7 @@ class Compiler
56905692
GenTree* fgOptimizeCast(GenTreeCast* cast);
56915693
GenTree* fgOptimizeEqualityComparisonWithConst(GenTreeOp* cmp);
56925694
GenTree* fgOptimizeRelationalComparisonWithConst(GenTreeOp* cmp);
5695+
GenTree* fgOptimizeRelationalComparisonWithFullRangeConst(GenTreeOp* cmp);
56935696
#ifdef FEATURE_HW_INTRINSICS
56945697
GenTree* fgOptimizeHWIntrinsic(GenTreeHWIntrinsic* node);
56955698
#endif

0 commit comments

Comments
 (0)