https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108447

--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Andrew Macleod from comment #23)
> (In reply to Jakub Jelinek from comment #21)
> > (In reply to Andrew Macleod from comment #19)
> > > Created attachment 54313 [details]
> > > better patch
> > > 
> > > A more consistent approach.. rather than directly call 
> > > relation_intersect()
> > > from multiple places, add the floating point fix to
> > > value_relation::intersect and always go through that.
> > > 
> > > This will cause the normal oracle and the path oracle to both make the
> > > previous adjustment to intersect for floating point operations.   
> > > untested,
> > > running tests now.
> > 
> > I thought (unless somebody proves otherwise) that relation_intersect is
> > actually just fine, the only thing that is incorrect (IMHO) for floating
> > point with NaNs are the
> 
> 
> I thought intersection was wrong for x <= y intersect x >= y because it
> produces x == y?

A floating point comparison when NANs is possible has 4 possible outcomes:
(1) x < y
(2) x == y
(3) x > y
(4) isnan (x) || isnan (y)
(unlike say integral which has only the 3 options).
Now, each of the C or tree comparisons can be expressed in a table for which of
those 4 outcomes it returns true.
Say:
x < y     (1)
x <= y    (1) || (2)
x > y     (3)
x >= y    (2) || (3)
x == y    (2)
x != y    (1) || (3) || (4)
VARYING   (1) || (2) || (3) || (4)
UNDEFINED
etc.
x <= y && x >= y from the above table is ((1) || (2)) && ((2) || (3)) aka (2)
aka x == y.
While x <= y || x >= y is (1) || (2) || (3) which is something we don't have a
VREL_*
name for (it is ORDERED_EXPR in trees).
Similarly x < y || x > y is (1) || (3) which we don't have either but is
LTGT_EXPR on trees.
For the integral cases when only (1), (2) and (3) are possible, all we need is
8
relations, LT, LE, GT, GE, EQ, NE, TRUE (VARYING) and FALSE (UNDEFINED) are
needed,
but for complete coverage of the 4 possibilities we need 16 (32 if it is also
about whether qNaN operand(s) raise exceptions or not).

E.g. AVX VCMP instruction has those 32 possibilities:

Predicate      imm8  Description         A > B A < B A = B Unordered Signal on
qNAN
EQ_OQ (EQ)       0H  Equal (ordered, non-signaling)                       F F T
F N
LT_OS (LT)       1H  Less-than (ordered, signaling)                       F T F
F Y
LE_OS (LE)       2H  Less-than-or-equal (ordered, signaling)              F T T
F Y
UNORD_Q (UNORD)  3H  Unordered (non-signaling)                            F F F
T N
NEQ_UQ (NEQ)     4H  Not-equal (unordered, non-signaling)                 T T F
T N
NLT_US (NLT)     5H  Not-less-than (unordered, signaling)                 T F T
T Y
NLE_US (NLE)     6H  Not-less-than-or-equal (unordered, signaling)        T F F
T Y
ORD_Q (ORD)      7H  Ordered (non-signaling)                              T T T
F N
EQ_UQ            8H  Equal (unordered, non-signaling)                     F F T
T N
NGE_US (NGE)     9H  Not-greater-than-or-equal (unordered, signaling)     F T F
T Y
NGT_US (NGT)     AH  Not-greater-than (unordered, signaling)              F T T
T Y
FALSE_OQ (FALSE) BH  False (ordered, non-signaling)                       F F F
F N
NEQ_OQ           CH  Not-equal (ordered, non-signaling)                   T T F
F N
GE_OS (GE)       DH  Greater-than-or-equal (ordered, signaling)           T F T
F Y
GT_OS (GT)       EH  Greater-than (ordered, signaling)                    T F F
F Y
TRUE_UQ(TRUE)    FH  True (unordered, non-signaling)                      T T T
T N
EQ_OS           10H  Equal (ordered, signaling)                           F F T
F Y
LT_OQ           11H  Less-than (ordered, non-signaling)                   F T F
F N
LE_OQ           12H  Less-than-or-equal (ordered, non-signaling)          F T T
F N
UNORD_S         13H  Unordered (signaling)                                F F F
T Y
NEQ_US          14H  Not-equal (unordered, signaling)                     T T F
T Y
NLT_UQ          15H  Not-less-than (unordered, non-signaling)             T F T
T N
NLE_UQ          16H  Not-less-than-or-equal (unordered, non-signaling)    T F F
T N
ORD_S           17H  Ordered (signaling)                                  T T T
F Y
EQ_US           18H  Equal (unordered, signaling)                         F F T
T Y
NGE_UQ          19H  Not-greater-than-or-equal (unordered, non-signaling) F T F
T N
NGT_UQ          1AH  Not-greater-than (unordered, non-signaling)          F T T
T N
FALSE_OS        1BH  False (ordered, signaling)                           F F F
F Y
NEQ_OS          1CH  Not-equal (ordered, signaling)                       T T F
F Y
GE_OQ           1DH  Greater-than-or-equal (ordered, non-signaling)       T F T
F N
GT_OQ           1EH  Greater-than (ordered, non-signaling)                T F F
F N
TRUE_US         1FH  True (unordered, signaling)                          T T T
T Y

I think for VREL_*, we could use just the 16, but for the time being need just
some
VREL_* value to represent those 8 that don't have a representation right now
(i.e. stand for I don't really know what the relation is).

Reply via email to