On 7/11/24 9:17 PM, HAO CHEN GUI wrote:
So why the test for real_isinf on the upper/lower bound? If op1 is known to be
a NaN, then why test the bounds at all? If a bounds test is needed, why only
test the upper bound?
IMHO, logical is if the op1 is a NAN, it's not an infinite number. If the upper
and lower bound both are finite numbers, the op1 is not an infinite number.
Under both situations, the result should be set to 0 which means op1 isn't an
infinite number.
Understood, but that's not what the code actually implements:
+ if (op1.known_isnan ()
+ || (!real_isinf (&op1.lower_bound ())
+ && !real_isinf (&op1.upper_bound ())))
+ {
+ r.set_zero (type);
+ return true;
+ }
If op1 is a NaN, then it it can not be Inf. Similarly if both of the
bounds are known not to be Inf, then op1 is not Inf and thus we should
be returning false instead of true. Or am I mis-understanding this API?
+ virtual bool op1_range (frange &r, tree type, const irange &lhs,
+ const frange &, relation_trio) const override
+ {
+ if (lhs.undefined_p ())
+ return false;
+
+ if (lhs.zero_p ())
+ {
+ nan_state nan (true);
+ r.set (type, real_min_representable (type),
+ real_max_representable (type), nan);
+ return true;
+ }
If the result of a builtin_isinf is zero, that doesn't mean the input has a nan
state. It means we know it's not infinity. The input argument could be
anything but an Inf.
If the result of a builtin_isinf is zero, it means the input might be a NAN or
a finite number. So the range should be [min_rep, max_rep] U NAN.
ACK.
jeff