public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108540] New: [13 Regression] Frange miscompilation of ruby since r13-3261
@ 2023-01-25 15:48 jakub at gcc dot gnu.org
  2023-01-25 15:52 ` [Bug tree-optimization/108540] " jakub at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-25 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108540
           Summary: [13 Regression] Frange miscompilation of ruby since
                    r13-3261
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

Since r13-3261-ga0c1a059101a3067d96211cbc4fae5905796d1db ruby is miscompiled
with LTO on powerpc64le-linux.
I've hand reduced it to:
#include <stdarg.h>

__attribute__((noipa)) void
bar (const char *cp, unsigned long size, char sign, int dsgn)
{
  if (__builtin_strcmp (cp, "ZERO") != 0 || size != 4 || sign != '-' || dsgn !=
1)
    __builtin_abort ();
}

__attribute__((noipa)) void
foo (int x, int ch, ...)
{
  va_list ap;
  const char *cp = "";
  unsigned long size = 0;
  char sign = '\0';
  double d;
  va_start (ap, ch);
  switch (x)
    {
    case 42:
      d = va_arg (ap, double);
      if (__builtin_isinf (d))
        {
          if (d < 0)
            sign = '-';
          cp = "Inf";
          size = 3;
          break;
        }
      if (__builtin_isnan (d))
        {
          cp = "NaN";
          size = 3;
          break;
        }
      if (d < 0)
        {
          d = -d;
          sign = '-';
        }
      else if (d == 0.0 && __builtin_signbit (d))
        sign = '-';
      else
        sign = '\0';
      if (ch == 'a' || ch == 'A')
        {
          union U { long long l; double d; } u;
          int dsgn;
          u.d = d;
          if (u.l < 0)
            {
              dsgn = 1;
              u.l &= 0x7fffffffffffffffLL;
            }
          else
            dsgn = 0;
          if (__builtin_isinf (d))
            {
              cp = "INF";
              size = 3;
            }
          else if (__builtin_isnan (d))
            {
              cp = "NAN";
              size = 3;
            }
          else if (d == 0)
            {
              cp = "ZERO";
              size = 4;
            }
          else
            {
              cp = "WRONG";
              size = 5;
            }
          bar (cp, size, sign, dsgn);
        }
    }
  va_end (ap);
}

int
main ()
{
  foo (42, 'a', -0.0);
  return 0;
}

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

end of thread, other threads:[~2023-01-27 20:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 15:48 [Bug tree-optimization/108540] New: [13 Regression] Frange miscompilation of ruby since r13-3261 jakub at gcc dot gnu.org
2023-01-25 15:52 ` [Bug tree-optimization/108540] " jakub at gcc dot gnu.org
2023-01-26 11:27 ` jakub at gcc dot gnu.org
2023-01-26 11:41 ` jakub at gcc dot gnu.org
2023-01-26 12:16 ` jakub at gcc dot gnu.org
2023-01-26 12:37 ` jakub at gcc dot gnu.org
2023-01-26 13:08 ` jakub at gcc dot gnu.org
2023-01-26 13:29 ` aldyh at gcc dot gnu.org
2023-01-26 16:28 ` cvs-commit at gcc dot gnu.org
2023-01-27 20:39 ` jakub 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).