public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/110755] New: Wrong optimization of fabs on ppc64el at -O1
@ 2023-07-20 20:18 aurelien at aurel32 dot net
  2023-07-20 20:25 ` [Bug target/110755] " pinskia at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: aurelien at aurel32 dot net @ 2023-07-20 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110755
           Summary: Wrong optimization of fabs on ppc64el at -O1
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aurelien at aurel32 dot net
  Target Milestone: ---

The following code, extracted and simplified from the PowerPC implementation of
nearbyintf() in the GNU libc is wrongly optimized at -O1 and -O2 on ppc64el
with GCC 13. The fabs is removed, while it is not the case with GCC 12

#include <fenv.h>
#include <math.h>
#include <stdio.h>

static float my_nearbyintf (float x)
{ 
  float r = x;

  if (x > 0.0)
    { 
      r += 0x1p+23;
      r -= 0x1p+23;
      r = fabs (r);
    }

  return r;
}

int main()
{
        volatile float in = 0.5f;

        fesetround (FE_DOWNWARD);
        printf("mynearbyintf(in) = %lf\n", my_nearbyintf(in));
}

This causes the result to have the wrong sign.

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

end of thread, other threads:[~2023-11-06  2:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 20:18 [Bug target/110755] New: Wrong optimization of fabs on ppc64el at -O1 aurelien at aurel32 dot net
2023-07-20 20:25 ` [Bug target/110755] " pinskia at gcc dot gnu.org
2023-07-20 20:28 ` aurelien at aurel32 dot net
2023-07-20 20:31 ` [Bug tree-optimization/110755] [13/14 Regression] " pinskia at gcc dot gnu.org
2023-07-21  6:56 ` rguenth at gcc dot gnu.org
2023-07-21  8:11 ` jakub at gcc dot gnu.org
2023-07-21  8:38 ` jakub at gcc dot gnu.org
2023-07-22 20:20 ` aurelien at aurel32 dot net
2023-07-24  7:12 ` jakub at gcc dot gnu.org
2023-07-24  7:47 ` jakub at gcc dot gnu.org
2023-07-24 18:31 ` aurelien at aurel32 dot net
2023-07-26  8:52 ` cvs-commit at gcc dot gnu.org
2023-07-26 10:00 ` [Bug tree-optimization/110755] [13 " jakub at gcc dot gnu.org
2023-07-27  9:27 ` rguenth at gcc dot gnu.org
2023-07-27 17:53 ` cvs-commit at gcc dot gnu.org
2023-08-30 22:21 ` jakub at gcc dot gnu.org
2023-11-06  2:38 ` hp 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).