public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/113234] New: missing folding to builtin_isunordered if manual nan comparison is used
@ 2024-01-04 14:52 denis.campredon at gmail dot com
  2024-01-04 15:38 ` [Bug rtl-optimization/113234] " jsm28 at gcc dot gnu.org
  2024-01-04 15:44 ` [Bug tree-optimization/113234] " pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: denis.campredon at gmail dot com @ 2024-01-04 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113234
           Summary: missing folding to builtin_isunordered if manual nan
                    comparison is used
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: denis.campredon at gmail dot com
  Target Milestone: ---

Compiled with -O1, on x86-64, f1 and f2 should produce the same code than f3
and f4, but f1 and f2 use two comparisons whereas f3 and f4 only use 1.


-------------------
bool f1(float i, float j)
{
    return i !=i || j != j;
}

bool f2(float i, float j)
{
    return i == i && j == j;
}

bool f3(float i, float j)
{
    return __builtin_isnan(i) || __builtin_isnan(j);
}

bool f4(float i, float j)
{
    return !__builtin_isnan(i) && !__builtin_isnan(j);
}
-------------------------------


It seems that gcc does not fold "f != f" to __builtin_isnan, or too late,
leading to the missed optimisation.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug rtl-optimization/113234] missing folding to builtin_isunordered if manual nan comparison is used
  2024-01-04 14:52 [Bug rtl-optimization/113234] New: missing folding to builtin_isunordered if manual nan comparison is used denis.campredon at gmail dot com
@ 2024-01-04 15:38 ` jsm28 at gcc dot gnu.org
  2024-01-04 15:44 ` [Bug tree-optimization/113234] " pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-01-04 15:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Note that if flag_signaling_nans, __builtin_isnan should not raise exceptions
for signaling NaN argument (bug 66462), but ==, != and __builtin_isunordered
should raise exceptions for signaling NaN argument.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/113234] missing folding to builtin_isunordered if manual nan comparison is used
  2024-01-04 14:52 [Bug rtl-optimization/113234] New: missing folding to builtin_isunordered if manual nan comparison is used denis.campredon at gmail dot com
  2024-01-04 15:38 ` [Bug rtl-optimization/113234] " jsm28 at gcc dot gnu.org
@ 2024-01-04 15:44 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-04 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|rtl-optimization            |tree-optimization
   Last reconfirmed|                            |2024-01-04
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Even with -fno-trapping-math, we don't combine:

  _1 = i_3(D) != i_3(D);
  _2 = j_4(D) != j_4(D);
  _5 = _1 | _2;

into:

  _5 = i_2(D) unord j_3(D);


Confirmed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-04 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04 14:52 [Bug rtl-optimization/113234] New: missing folding to builtin_isunordered if manual nan comparison is used denis.campredon at gmail dot com
2024-01-04 15:38 ` [Bug rtl-optimization/113234] " jsm28 at gcc dot gnu.org
2024-01-04 15:44 ` [Bug tree-optimization/113234] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).