Discussion:
target specific option mismatch?
Matthias Kretz
2011-04-15 09:04:35 UTC
Permalink
Hi,

I experience a miscompile with GCC 4.6.0 (#48616) and was trying to implement
a workaround in my library, but no success. The bug is connected to use of the
XOP instruction set and -ftree-vectorize. So I thought I can just disable one
or both of those in the function where the miscompile happens. But that
function is a member of a template class and thus inlined. Apparently that
leads to neither "#pragma GCC optimize/target" nor
"__attribute__((optimize/target))" changing anything, or is that another bug?

Anyway this is what I got:

#define VC_WORKAROUND __attribute__((optimize("no-tree-vectorize"),target("no-
xop")))

template<> inline Vector<T> &VC_WORKAROUND VectorBase<T>::operator>>=(const
VectorBase<T> &x)
{
for_all_vector_entries(i,
d.m(i) >>= x.d.m(i);
);
return *static_cast<Vector<T> *>(this);
}

vector.tcc:286:1: sorry, unimplemented: inlining failed in call to
‘Vc::SSE::Vector<T>& Vc::SSE::VectorBase<T>::operator<<=(const
Vc::SSE::VectorBase<T>&) [with T = int]’: target specific option mismatch


Any suggestions how to implement a workaround?

Cheers,
Matthias
--
Dipl.-Phys. Matthias Kretz
http://compeng.uni-frankfurt.de/?mkretz

SIMD easy and portable: http://compeng.uni-frankfurt.de/?vc
Ian Lance Taylor
2011-04-15 14:50:37 UTC
Permalink
Post by Matthias Kretz
I experience a miscompile with GCC 4.6.0 (#48616) and was trying to implement
a workaround in my library, but no success. The bug is connected to use of the
XOP instruction set and -ftree-vectorize. So I thought I can just disable one
or both of those in the function where the miscompile happens. But that
function is a member of a template class and thus inlined. Apparently that
leads to neither "#pragma GCC optimize/target" nor
"__attribute__((optimize/target))" changing anything, or is that another bug?
#define VC_WORKAROUND __attribute__((optimize("no-tree-vectorize"),target("no-
xop")))
template<> inline Vector<T> &VC_WORKAROUND VectorBase<T>::operator>>=(const
VectorBase<T> &x)
{
for_all_vector_entries(i,
d.m(i) >>= x.d.m(i);
);
return *static_cast<Vector<T> *>(this);
}
vector.tcc:286:1: sorry, unimplemented: inlining failed in call to
‘Vc::SSE::Vector<T>& Vc::SSE::VectorBase<T>::operator<<=(const
Vc::SSE::VectorBase<T>&) [with T = int]’: target specific option mismatch
Any suggestions how to implement a workaround?
I have no suggestions for a workaround, but I don't think this should
fail with an error like this for a function that does not have the
always_inline attribute. It should just not inline, and give a warning
with -Winline. Please consider opening a bug report. Thanks.

Ian
Matthias Kretz
2011-04-15 15:00:39 UTC
Permalink
Hi,
Post by Ian Lance Taylor
Post by Matthias Kretz
#define VC_WORKAROUND
__attribute__((optimize("no-tree-vectorize"),target("no- xop")))
template<> inline Vector<T> &VC_WORKAROUND
VectorBase<T>::operator>>=(const VectorBase<T> &x)
{
for_all_vector_entries(i,
d.m(i) >>= x.d.m(i);
);
return *static_cast<Vector<T> *>(this);
}
vector.tcc:286:1: sorry, unimplemented: inlining failed in call to
‘Vc::SSE::Vector<T>& Vc::SSE::VectorBase<T>::operator<<=(const
Vc::SSE::VectorBase<T>&) [with T = int]’: target specific option mismatch
I have no suggestions for a workaround, but I don't think this should
fail with an error like this for a function that does not have the
always_inline attribute. It should just not inline, and give a warning
with -Winline. Please consider opening a bug report. Thanks.
How about
#define VC_WORKAROUND_IN
#define VC_WORKAROUND __attribute__((optimize("no-tree-vectorize"),target("no-
xop"),weak)

template<> VC_WORKAROUND_IN Vector<T> &VC_WORKAROUND
VectorBase<T>::operator>>=(const VectorBase<T> &x) {

AFAIU the weak attribute is required. Otherwise, since this function is
defined in a header, one would get link errors if the function is used with
the same T in more than one compilation unit, no?

Regards,
Matthias
--
Dipl.-Phys. Matthias Kretz
http://compeng.uni-frankfurt.de/?mkretz

SIMD easy and portable: http://compeng.uni-frankfurt.de/?vc
Loading...