On Wed, 23 Aug 2017, Uros Bizjak wrote:

> On Wed, Aug 23, 2017 at 11:22 AM, Richard Biener <rguent...@suse.de> wrote:
> >> >  /* If the machine does not have a case insn that compares the bounds,
> >> > Index: gcc/config/i386/i386.c
> >> > ===================================================================
> >> > --- gcc/config/i386/i386.c      (revision 251275)
> >> > +++ gcc/config/i386/i386.c      (working copy)
> >> > @@ -7369,7 +7369,8 @@ ix86_valid_target_attribute_tree (tree a
> >> >        || opts->x_target_flags != def->x_target_flags
> >> >        || option_strings[IX86_FUNCTION_SPECIFIC_ARCH]
> >> >        || option_strings[IX86_FUNCTION_SPECIFIC_TUNE]
> >> > -      || enum_opts_set.x_ix86_fpmath)
> >> > +      || enum_opts_set.x_ix86_fpmath
> >> > +      || !TARGET_64BIT_P (opts->x_ix86_isa_flags))
> >>
> >> You should use (!TARGET_64BIT_P ... && TARGET_SSE_P ...) to match the
> >> condition in the special fpmath processing part. (BTW: The comment in
> >> that part is wrong, we need SSE, not sse2 on 32-bit targets to use SSE
> >> math.)
> >
> > Hmpf, with the change I again run into the libgo bootstrap fail
> > (appearantly my reduced testcase is incomplete)
> >
> > libtool: compile:  /abuild/rguenther/obj2/./gcc/xgcc
> > -B/abuild/rguenther/obj2/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
> > -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
> > /usr/local/x86_64-pc-linux-gnu/include -isystem
> > /usr/local/x86_64-pc-linux-gnu/sys-include -m32 -DHAVE_CONFIG_H -I.
> > -I/space/rguenther/src/svn/trunk2/libgo -I
> > /space/rguenther/src/svn/trunk2/libgo/runtime
> > -I/space/rguenther/src/svn/trunk2/libgo/../libffi/include
> > -I../libffi/include -pthread -fexceptions -fnon-call-exceptions
> > -fplan9-extensions -fsplit-stack -Wall -Wextra -Wwrite-strings -Wcast-qual
> > -Werror -minline-all-stringops -D_GNU_SOURCE -D_LARGEFILE_SOURCE
> > -D_FILE_OFFSET_BITS=64 -I /space/rguenther/src/svn/trunk2/libgo/../libgcc
> > -I /space/rguenther/src/svn/trunk2/libgo/../libbacktrace -I
> > ../../../gcc/include -g -O2 -m32 -MT aeshash.lo -MD -MP -MF
> > .deps/aeshash.Tpo -c
> > /space/rguenther/src/svn/trunk2/libgo/runtime/aeshash.c  -fPIC -DPIC -o
> > .libs/aeshash.o
> > In file included from
> > /space/rguenther/src/svn/trunk2/libgo/runtime/aeshash.c:17:0:
> > /space/rguenther/src/svn/trunk2/libgo/runtime/aeshash.c: In function
> > ‘aeshashbody’:
> > /abuild/rguenther/obj2/./gcc/include/emmintrin.h:700:1: error: inlining
> > failed in call to always_inline ‘_mm_loadu_si128’: target specific option
> > mismatch
> >  _mm_loadu_si128 (__m128i_u const *__P)
> >  ^~~~~~~~~~~~~~~
> > /space/rguenther/src/svn/trunk2/libgo/runtime/aeshash.c:387:11: note:
> > called from here
> >   mseed ^= _mm_loadu_si128(aeskeysched.__values);
> >            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > that appens even with making the if a if (1).  The check we run into
> > is somehow still
> >
> >   else if (caller_opts->x_ix86_fpmath != callee_opts->x_ix86_fpmath)
> >     ret = false;
> >
> > ah ...
> >
> > #ifndef __SSE__
> > #pragma GCC push_options
> > #pragma GCC target("sse")
> > #define __DISABLE_SSE__
> > #endif /* __SSE__ */
> >
> > but on x86_64 when building with -m32 we _do_ have __SSE__ set so
> > the intrinsics get target_option_default_node which doesn't have
> > fmpath=sse.  So x86_64 -m32 -march=i586 enables SSE math for
> > the intrinsics while x86_64 -m32 [-march=x86-64] does not...
> 
> IMO target_default_node should already enable fpmath=sse. When SSE is
> available, fpmath should be set to SSE, unless there is fpmath option
> specified.

It is documented to be 387: "This is the default choice for non-Darwin 
x86-32 targets."

Relaxing the fpmath test to

+  else if ((caller_opts->x_ix86_fpmath & callee_opts->x_ix86_fpmath) == 
0)
+    ret = false;

fixes the build.  Of course that might not be strictly ok.

So yes, we could change the default for fpmath, or we can unconditionally
apply the Pragma.

See PR81941 how fpmath is unfortunate (you generally don't want to
enable 387 for 64bit but it would be necessary to fix intrinsic
inlining for -m32).

Richard.

Reply via email to