diff mbox

Work around miscompilation with 4.8.1

Message ID 1410560868-11154-1-git-send-email-andi@firstfloor.org
State New
Headers show

Commit Message

Andi Kleen Sept. 12, 2014, 10:27 p.m. UTC
From: Andi Kleen <ak@linux.intel.com>

When compiling on opensuse 13.1, with a 4.8.1 based host compiler
and --disable-bootstrap, the generated compiler always ICEs while
compiling __builtin_cpu_supports in the cilk runtime library.

The problem is fixed with later 4.8 releases, but at least still
happens with the opensuse compiler.

The cilk library already had a fallback path for this function
for other compilers. Just use the fallback path when
__SSE2_MATH__ is set. This makes it work on x86_64 systems
with the buggy 4.8.1 at least, if multilib is forced to
SSE.

libcilkrts/:

2014-09-12  Andi Kleen  <ak@linux.intel.com>

	PR bootstrap/63235
	* runtime/config/x86/os-unix-sysdep.c (__builtin_cpu_supports):
	Use fallback when __SSE2_MATH__ is set.
---
 libcilkrts/runtime/config/x86/os-unix-sysdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

H.J. Lu Sept. 13, 2014, 12:10 a.m. UTC | #1
On Fri, Sep 12, 2014 at 3:27 PM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> When compiling on opensuse 13.1, with a 4.8.1 based host compiler
> and --disable-bootstrap, the generated compiler always ICEs while
> compiling __builtin_cpu_supports in the cilk runtime library.
>
> The problem is fixed with later 4.8 releases, but at least still
> happens with the opensuse compiler.
>
> The cilk library already had a fallback path for this function
> for other compilers. Just use the fallback path when
> __SSE2_MATH__ is set. This makes it work on x86_64 systems
> with the buggy 4.8.1 at least, if multilib is forced to
> SSE.
>
> libcilkrts/:
>
> 2014-09-12  Andi Kleen  <ak@linux.intel.com>
>
>         PR bootstrap/63235
>         * runtime/config/x86/os-unix-sysdep.c (__builtin_cpu_supports):
>         Use fallback when __SSE2_MATH__ is set.
> ---
>  libcilkrts/runtime/config/x86/os-unix-sysdep.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libcilkrts/runtime/config/x86/os-unix-sysdep.c b/libcilkrts/runtime/config/x86/os-unix-sysdep.c
> index b505ddf..344c31a 100644
> --- a/libcilkrts/runtime/config/x86/os-unix-sysdep.c
> +++ b/libcilkrts/runtime/config/x86/os-unix-sysdep.c
> @@ -96,7 +96,7 @@ COMMON_SYSDEP int __cilkrts_xchg(volatile int *ptr, int x)
>   * This declaration should generate an error when the Intel compiler adds
>   * supprt for the intrinsic.
>   */
> -#ifdef __INTEL_COMPILER
> +#if defined(__INTEL_COMPILER) || defined(__SSE2_MATH__)
>  static inline int __builtin_cpu_supports(const char *feature)
>  {
>      return 1;

So GCC 4.8.1 miscompiles GCC.  Can we trust such GCC?
Should we put a work around in GCC compiler to avoid the
bad GCC?

BTW,  I run into another miscompilation bug

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

It only shows up when GCC is compiled with -O2 using GCC 5
on x32.
diff mbox

Patch

diff --git a/libcilkrts/runtime/config/x86/os-unix-sysdep.c b/libcilkrts/runtime/config/x86/os-unix-sysdep.c
index b505ddf..344c31a 100644
--- a/libcilkrts/runtime/config/x86/os-unix-sysdep.c
+++ b/libcilkrts/runtime/config/x86/os-unix-sysdep.c
@@ -96,7 +96,7 @@  COMMON_SYSDEP int __cilkrts_xchg(volatile int *ptr, int x)
  * This declaration should generate an error when the Intel compiler adds
  * supprt for the intrinsic.
  */
-#ifdef __INTEL_COMPILER
+#if defined(__INTEL_COMPILER) || defined(__SSE2_MATH__)
 static inline int __builtin_cpu_supports(const char *feature)
 {
     return 1;