This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch/RFC] libstdc++/20610
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: 24 Mar 2005 16:38:29 +0100
- Subject: Re: [Patch/RFC] libstdc++/20610
- Organization: Integrable Solutions
- References: <42429705.2040402@suse.de>
Paolo Carlini <pcarlini@suse.de> writes:
| Hi,
|
| Fredrik noticed that the code we produce for complex * real is
| suboptimal. The primary template for operator*= is:
|
| template<typename _Tp>
| complex<_Tp>&
| complex<_Tp>::operator*=(const _Tp& __t)
| {
| _M_real *= __t;
| _M_imag *= __t;
| return *this;
| }
|
| whereas the specializations read (f.i., for double):
|
| inline complex<double>&
| complex<double>::operator*=(double __d)
| {
| _M_value *= __d;
| return *this;
| }
|
| A simple fix for this issue is expanding the latter to:
|
| inline complex<double>&
| complex<double>::operator*=(double __d)
| {
| __real__ _M_value *= __d;
| __imag__ _M_value *= __d;
| return *this;
| }
This really is again a compiler issue. _M_value, in the specialization, is
of type "double _Complex", which means that it is also a problem in
C-land. Have the compiler do the obvious thing, namely tranform
_M_value *= d
into
__real__ _M_value *= d
__imag__ _M_value *= d
if it is known, as you report, that is what gives better code.
This looks to me to be a simple vectorization issue.
Let's fix the problem, not its symptoms.
-- Gaby