PPC_FP128 determines isZero/isNan/isInf using high-order double value
only. Checking isZero/isNegative might return the isNullValue unexpectedly.
eg:
0xM0000000000000000FFFFFFFFFFFFFFFFF
isZero, but it is not NullValue.
Differential D103634
[Constants][PowerPC] Check exactlyValue for ppc_fp128 in isNullValue jsji on Jun 3 2021, 10:45 AM. Authored by
Details
PPC_FP128 determines isZero/isNan/isInf using high-order double value 0xM0000000000000000FFFFFFFFFFFFFFFFF isZero, but it is not NullValue.
Diff Detail
Event TimelineComment Actions If Constant::isNullValue() isn't returning the right result, please fix it directly. Getting it wrong could have other unexpected consequences. Comment Actions Thanks @efriedma for the comments. In this case Constant::isNullValue() is correct, as the value is indeed a NullValue for ppc_fp128. Yes, we will need to deal with this special cases carefully in other optimizations as well to avoid unexpected consequences. The fix is for BitcodeWriters, so that we won't end up clear bits unexpected, which causes unexpected different behaviors using bitcode vs. IR. Comment Actions Constant::isNullValue() is supposed to mean "is this value all zero bits"; various parts of the code use it that way. It shouldn't care whether the value is semantically equal to zero. Anything doing floating-point arithmetic should be using the appropriate ConstantFP/APFloat methods. Comment Actions LGTM with one minor comment.
|
We can use isExactlyValue() for all floating-point types; no reason to have two separate codepaths.