public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/31485]  New: C complex numbers, amd64 SSE, missed optimization opportunity
@ 2007-04-05 11:29 bisqwit at iki dot fi
  2007-04-09 17:48 ` [Bug rtl-optimization/31485] " rguenth at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 27+ messages in thread
From: bisqwit at iki dot fi @ 2007-04-05 11:29 UTC (permalink / raw)
  To: gcc-bugs

Considering that "complex" turns basically any basic type into a vector type,
complex number addition and subtraction could utilize SSE instructions to
perform the operation on real and imaginary parts simultaneously. (Only applies
to addition and subtraction.)

Code:

#include <complex.h>

typedef float complex ss1;
typedef float ss2 __attribute__((vector_size(sizeof(ss1))));

ss1 add1(ss1 a, ss1 b) { return a + b; }
ss2 add2(ss2 a, ss2 b) { return a + b; }

Produces:

add1:
        movq    %xmm0, -8(%rsp)
        movq    %xmm1, -16(%rsp)
        movss   -4(%rsp), %xmm0
        movss   -8(%rsp), %xmm1
        addss   -12(%rsp), %xmm0
        addss   -16(%rsp), %xmm1
        movss   %xmm0, -20(%rsp)
        movss   %xmm1, -24(%rsp)
        movq    -24(%rsp), %xmm0
        ret
add2:
        movlps  %xmm0, -16(%rsp)
        movlps  %xmm1, -24(%rsp)
        movaps  -24(%rsp), %xmm0
        addps   -16(%rsp), %xmm0
        movaps  %xmm0, -56(%rsp)
        movlps  -56(%rsp), %xmm0
        ret

Command line:
    gcc -msse  -O3 -S test2.c
    (Results are same with -ffast-math)
Architecture:
CPU=AMD Athlon(tm) 64 X2 Dual Core Processor 4600+
CPU features=fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat
pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt lm 3dnowext 3dnow
pni lahf_lm cmp_legacy

GCC is:
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release
x86_64-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)


-- 
           Summary: C complex numbers, amd64 SSE, missed optimization
                    opportunity
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bisqwit at iki dot fi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31485


^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <bug-31485-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-08-16 21:29 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-05 11:29 [Bug rtl-optimization/31485] New: C complex numbers, amd64 SSE, missed optimization opportunity bisqwit at iki dot fi
2007-04-09 17:48 ` [Bug rtl-optimization/31485] " rguenth at gcc dot gnu dot org
2008-07-29 22:07 ` victork at gcc dot gnu dot org
2008-08-02 12:23 ` rguenth at gcc dot gnu dot org
2008-08-02 13:01 ` ubizjak at gmail dot com
2008-08-02 13:19 ` rguenth at gcc dot gnu dot org
2010-04-17  0:28 ` ddesics at gmail dot com
2010-04-17 11:11 ` rguenth at gcc dot gnu dot org
2010-04-21 11:33 ` irar at il dot ibm dot com
2010-04-21 11:44 ` rguenther at suse dot de
2010-04-21 18:34 ` irar at il dot ibm dot com
     [not found] <bug-31485-4@http.gcc.gnu.org/bugzilla/>
2020-04-21  6:43 ` bisqwit at iki dot fi
2020-04-21  7:07 ` rguenth at gcc dot gnu.org
2020-04-21  7:17 ` bisqwit at iki dot fi
2020-04-21  7:37 ` rguenth at gcc dot gnu.org
2020-04-21  8:18 ` bisqwit at iki dot fi
2020-04-21  8:23 ` jakub at gcc dot gnu.org
2020-04-21  8:29 ` rguenther at suse dot de
2020-04-21  8:32 ` jakub at gcc dot gnu.org
2020-04-21  8:33 ` jakub at gcc dot gnu.org
2020-04-21  8:34 ` bisqwit at iki dot fi
2020-04-21  8:43 ` jakub at gcc dot gnu.org
2020-04-21  8:47 ` rguenther at suse dot de
2020-04-21  8:51 ` bisqwit at iki dot fi
2020-04-21  8:58 ` jakub at gcc dot gnu.org
2020-04-21  9:06 ` bisqwit at iki dot fi
2021-08-16 21:29 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).