public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/59379] [4.9 Regression] gomp_init_num_threads is compiled into an infinite loop with --with-arch=corei7  --with-cpu=slm
Date: Fri, 06 Dec 2013 01:45:00 -0000	[thread overview]
Message-ID: <bug-59379-4-HSx8Ajen6a@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59379-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59379

--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> ---
A small run-time testcase.  It went into an finite loop at -O.

---
[hjl@gnu-mic-2 pr59379]$ cat main.c 
#include <stdlib.h>
typedef unsigned long int __cpu_mask;
void *
__attribute__((malloc, noinline))
gomp_malloc (size_t s)
{
  return malloc (s);
}
typedef struct
{
  __cpu_mask __bits[1024 / (8 * sizeof (__cpu_mask))];
} cpu_set_t;
unsigned long gomp_cpuset_size __attribute__ ((visibility ("hidden")));
cpu_set_t *gomp_cpusetp __attribute__ ((visibility ("hidden")));
static unsigned long gomp_get_cpuset_size;
void
__attribute__ ((noinline))
gomp_init_num_threads (void)
{
  gomp_cpuset_size = 8;
  gomp_cpusetp = (cpu_set_t *) gomp_malloc (gomp_cpuset_size);
  do
    {
      gomp_get_cpuset_size = gomp_cpuset_size;
      unsigned long i;
      for (i = gomp_cpuset_size * 8; i; i--)
    if ((__extension__
         ({ size_t __cpu = (i - 1);
          __cpu < 8 * (gomp_cpuset_size)
          ? ((((const __cpu_mask *) ((gomp_cpusetp)->__bits))[((__cpu) / (8 *
sizeof (__cpu_mask)))] & ((__cpu_mask) 1 << ((__cpu) % (8 * sizeof
(__cpu_mask)))))) != 0
          : 0;
          })))
      break;
      gomp_cpuset_size = ((((i) + (8 * sizeof (__cpu_mask)) - 1) / (8 * sizeof
(__cpu_mask))) * sizeof (__cpu_mask));
      return;
    }
  while (1);
}
int
main ()
{
  gomp_init_num_threads ();
  return 0;
}
[hjl@gnu-mic-2 pr59379]$ make run
/export/build/gnu/gcc-lto-fdo/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-lto-fdo/build-x86_64-linux/gcc/ -O -o x main.c
./x
make: *** wait: No child processes.  Stop.
make: *** Waiting for unfinished jobs....
make: *** wait: No child processes.  Stop.
---


  parent reply	other threads:[~2013-12-06  1:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 21:40 [Bug target/59379] New: " hjl.tools at gmail dot com
2013-12-03 21:46 ` [Bug target/59379] " octoploid at yandex dot com
2013-12-03 21:51 ` hjl.tools at gmail dot com
2013-12-03 21:52 ` hjl.tools at gmail dot com
2013-12-04  0:41 ` hjl.tools at gmail dot com
2013-12-04  0:48 ` hjl.tools at gmail dot com
2013-12-04 10:52 ` [Bug target/59379] [4.9 Regression] " hjl.tools at gmail dot com
2013-12-04 23:39 ` hjl.tools at gmail dot com
2013-12-05  3:11 ` hjl.tools at gmail dot com
2013-12-05 11:17 ` rguenth at gcc dot gnu.org
2013-12-06  1:45 ` hjl.tools at gmail dot com [this message]
2013-12-19 15:37 ` rguenth at gcc dot gnu.org
2013-12-26 12:41 ` izamyatin at gmail dot com
2013-12-26 12:57 ` hjl.tools at gmail dot com
2013-12-26 14:41 ` hjl.tools at gmail dot com
2013-12-30 21:16 ` izamyatin at gmail dot com
2013-12-31  7:02 ` izamyatin at gmail dot com
2014-01-18 17:13 ` hjl.tools at gmail dot com
2014-01-18 19:47 ` ubizjak at gmail dot com
2014-01-19  9:51 ` ubizjak at gmail dot com
2014-01-19 14:18 ` hjl.tools at gmail dot com
2014-01-19 15:48 ` uros at gcc dot gnu.org
2014-01-22 18:29 ` uros at gcc dot gnu.org
2014-01-22 18:40 ` ubizjak at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-59379-4-HSx8Ajen6a@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).