diff options
author | Brian Sullivan <briansul@microsoft.com> | 2018-09-17 13:39:18 -0700 |
---|---|---|
committer | Brian Sullivan <briansul@microsoft.com> | 2018-09-19 11:07:02 -0700 |
commit | 8797f7a36aec5df957f28e4c9e09c22cc5fe5484 (patch) | |
tree | 41d056581ae923b10eaa4d270b88ddbc2015c6c5 /src/jit/valuenum.cpp | |
parent | 541f710095b6c10f2e650ad68e3f5961aa467d02 (diff) | |
download | coreclr-8797f7a36aec5df957f28e4c9e09c22cc5fe5484.tar.gz coreclr-8797f7a36aec5df957f28e4c9e09c22cc5fe5484.tar.bz2 coreclr-8797f7a36aec5df957f28e4c9e09c22cc5fe5484.zip |
Changes to use VNNormalValue in assertionProp
Diffstat (limited to 'src/jit/valuenum.cpp')
-rw-r--r-- | src/jit/valuenum.cpp | 103 |
1 files changed, 45 insertions, 58 deletions
diff --git a/src/jit/valuenum.cpp b/src/jit/valuenum.cpp index bdb13eba91..8b6d9c5beb 100644 --- a/src/jit/valuenum.cpp +++ b/src/jit/valuenum.cpp @@ -639,7 +639,7 @@ T ValueNumStore::EvalOpSpecialized(VNFunc vnf, T v0) // template <typename T> -T ValueNumStore::EvalOp(VNFunc vnf, T v0, T v1, ValueNum* pExcSet) +T ValueNumStore::EvalOp(VNFunc vnf, T v0, T v1) { // Here we handle the binary ops that are the same for all types. @@ -2707,7 +2707,6 @@ ValueNum ValueNumStore::EvalFuncForConstantArgs(var_types typ, VNFunc func, Valu } ValueNum result; // left uninitialized, we are required to initialize it on all paths below. - ValueNum excSet = VNForEmptyExcSet(); // Are both args of the same type? if (arg0VNtyp == arg1VNtyp) @@ -2725,17 +2724,16 @@ ValueNum ValueNumStore::EvalFuncForConstantArgs(var_types typ, VNFunc func, Valu else { assert(typ == TYP_INT); - int resultVal = EvalOp<int>(func, arg0Val, arg1Val, &excSet); + int resultVal = EvalOp<int>(func, arg0Val, arg1Val); // Bin op on a handle results in a handle. ValueNum handleVN = IsVNHandle(arg0VN) ? arg0VN : IsVNHandle(arg1VN) ? arg1VN : NoVN; if (handleVN != NoVN) { - assert(excSet == VNForEmptyExcSet()); // Handles aren't allowed to generate exceptions result = VNForHandle(ssize_t(resultVal), GetHandleFlags(handleVN)); // Use VN for Handle } else { - result = VNWithExc(VNForIntCon(resultVal), excSet); + result = VNForIntCon(resultVal); } } } @@ -2752,12 +2750,17 @@ ValueNum ValueNumStore::EvalFuncForConstantArgs(var_types typ, VNFunc func, Valu else { assert(typ == TYP_LONG); - INT64 resultVal = EvalOp<INT64>(func, arg0Val, arg1Val, &excSet); + INT64 resultVal = EvalOp<INT64>(func, arg0Val, arg1Val); ValueNum handleVN = IsVNHandle(arg0VN) ? arg0VN : IsVNHandle(arg1VN) ? arg1VN : NoVN; - ValueNum resultVN = (handleVN != NoVN) - ? VNForHandle(ssize_t(resultVal), GetHandleFlags(handleVN)) // Use VN for Handle - : VNForLongCon(resultVal); - result = VNWithExc(resultVN, excSet); + + if (handleVN != NoVN) + { + result = VNForHandle(ssize_t(resultVal), GetHandleFlags(handleVN)); // Use VN for Handle + } + else + { + result = VNForLongCon(resultVal); + } } } else // both args are TYP_REF or both args are TYP_BYREF @@ -2772,14 +2775,14 @@ ValueNum ValueNumStore::EvalFuncForConstantArgs(var_types typ, VNFunc func, Valu } else if (typ == TYP_INT) // We could see GT_OR of a constant ByRef and Null { - int resultVal = (int)EvalOp<INT64>(func, arg0Val, arg1Val, &excSet); - result = VNWithExc(VNForIntCon(resultVal), excSet); + int resultVal = (int)EvalOp<INT64>(func, arg0Val, arg1Val); + result = VNForIntCon(resultVal); } else // We could see GT_OR of a constant ByRef and Null { assert((typ == TYP_BYREF) || (typ == TYP_LONG)); - INT64 resultVal = EvalOp<INT64>(func, arg0Val, arg1Val, &excSet); - result = VNWithExc(VNForByrefCon(resultVal), excSet); + INT64 resultVal = EvalOp<INT64>(func, arg0Val, arg1Val); + result = VNForByrefCon(resultVal); } } } @@ -2798,37 +2801,28 @@ ValueNum ValueNumStore::EvalFuncForConstantArgs(var_types typ, VNFunc func, Valu } else if (typ == TYP_INT) // We could see GT_OR of an int and constant ByRef or Null { - int resultVal = (int)EvalOp<INT64>(func, arg0Val, arg1Val, &excSet); - result = VNWithExc(VNForIntCon(resultVal), excSet); + int resultVal = (int)EvalOp<INT64>(func, arg0Val, arg1Val); + result = VNForIntCon(resultVal); } else { assert(typ != TYP_INT); - ValueNum resultValx = VNForEmptyExcSet(); - INT64 resultVal = EvalOp<INT64>(func, arg0Val, arg1Val, &resultValx); + INT64 resultVal = EvalOp<INT64>(func, arg0Val, arg1Val); - // check for the Exception case - if (resultValx != VNForEmptyExcSet()) - { - result = VNWithExc(VNForVoid(), resultValx); - } - else + switch (typ) { - switch (typ) - { - case TYP_BYREF: - result = VNForByrefCon(resultVal); - break; - case TYP_LONG: - result = VNForLongCon(resultVal); - break; - case TYP_REF: - assert(resultVal == 0); // Only valid REF constant - result = VNForNull(); - break; - default: - unreached(); - } + case TYP_BYREF: + result = VNForByrefCon(resultVal); + break; + case TYP_LONG: + result = VNForLongCon(resultVal); + break; + case TYP_REF: + assert(resultVal == 0); // Only valid REF constant + result = VNForNull(); + break; + default: + unreached(); } } } @@ -2876,23 +2870,17 @@ ValueNum ValueNumStore::EvalFuncForConstantFPArgs(var_types typ, VNFunc func, Va assert(varTypeIsFloating(typ)); assert(arg0VNtyp == typ); - ValueNum exception = VNForEmptyExcSet(); - if (typ == TYP_FLOAT) { - float floatResultVal = - EvalOp<float>(func, GetConstantSingle(arg0VN), GetConstantSingle(arg1VN), &exception); - assert(exception == VNForEmptyExcSet()); // Floating point ops don't throw. - result = VNForFloatCon(floatResultVal); + float floatResultVal = EvalOp<float>(func, GetConstantSingle(arg0VN), GetConstantSingle(arg1VN)); + result = VNForFloatCon(floatResultVal); } else { assert(typ == TYP_DOUBLE); - double doubleResultVal = - EvalOp<double>(func, GetConstantDouble(arg0VN), GetConstantDouble(arg1VN), &exception); - assert(exception == VNForEmptyExcSet()); // Floating point ops don't throw. - result = VNForDoubleCon(doubleResultVal); + double doubleResultVal = EvalOp<double>(func, GetConstantDouble(arg0VN), GetConstantDouble(arg1VN)); + result = VNForDoubleCon(doubleResultVal); } } @@ -8058,7 +8046,7 @@ ValueNumPair ValueNumStore::VNPairForCast(ValueNumPair srcVNPair, ValueNumPair castArgxVNP = ValueNumStore::VNPForEmptyExcSet(); VNPUnpackExc(srcVNPair, &castArgVNP, &castArgxVNP); - // When we're considering actual value returned by a non-checking cast (or a checking cast that succeeds), + // When we're considering actual value returned by a non-checking cast, (hasOverflowCheck is false) // whether or not the source is unsigned does *not* matter for non-widening casts. // That is, if we cast an int or a uint to short, we just extract the first two bytes from the source // bit pattern, not worrying about the interpretation. The same is true in casting between signed/unsigned @@ -8068,26 +8056,25 @@ ValueNumPair ValueNumStore::VNPairForCast(ValueNumPair srcVNPair, // Important: Casts to floating point cannot be optimized in this fashion. (bug 946768) // bool srcIsUnsignedNorm = srcIsUnsigned; - if (genTypeSize(castToType) <= genTypeSize(castFromType) && !varTypeIsFloating(castToType)) + if (!hasOverflowCheck && !varTypeIsFloating(castToType) && (genTypeSize(castToType) <= genTypeSize(castFromType))) { srcIsUnsignedNorm = false; } + VNFunc vnFunc = hasOverflowCheck ? VNF_CastOvf : VNF_Cast; ValueNum castTypeVN = VNForCastOper(castToType, srcIsUnsignedNorm); ValueNumPair castTypeVNPair(castTypeVN, castTypeVN); - ValueNumPair castNormRes = VNPairForFunc(resultType, VNF_Cast, castArgVNP, castTypeVNPair); + ValueNumPair castNormRes = VNPairForFunc(resultType, vnFunc, castArgVNP, castTypeVNPair); ValueNumPair resultVNP = VNPWithExc(castNormRes, castArgxVNP); // If we have a check for overflow, add the exception information. if (hasOverflowCheck) { - // For overflow checking, we always need to know whether the source is unsigned. - castTypeVNPair.SetBoth(VNForCastOper(castToType, srcIsUnsigned)); - ValueNumPair excSet = - VNPExcSetSingleton(VNPairForFunc(TYP_REF, VNF_ConvOverflowExc, castArgVNP, castTypeVNPair)); - excSet = VNPExcSetUnion(excSet, castArgxVNP); - resultVNP = VNPWithExc(castNormRes, excSet); + ValueNumPair ovfChk = VNPairForFunc(TYP_REF, VNF_ConvOverflowExc, castArgVNP, castTypeVNPair); + ValueNumPair excSet = VNPExcSetSingleton(ovfChk); + excSet = VNPExcSetUnion(excSet, castArgxVNP); + resultVNP = VNPWithExc(castNormRes, excSet); } return resultVNP; |