From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25909 invoked by alias); 6 Dec 2013 01:45:59 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25878 invoked by uid 48); 6 Dec 2013 01:45:56 -0000 From: "hjl.tools at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg00451.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59379 --- Comment #9 from H.J. Lu --- A small run-time testcase. It went into an finite loop at -O. --- [hjl@gnu-mic-2 pr59379]$ cat main.c #include 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. ---