public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53645] New: Missed optimization for division of vector types
@ 2012-06-12 12:45 andrii.riabushenko at barclays dot com
  2012-06-12 13:34 ` [Bug c/53645] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: andrii.riabushenko at barclays dot com @ 2012-06-12 12:45 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53645
           Summary: Missed optimization for division of vector types
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: andrii.riabushenko@barclays.com


for the following code

v4si ttt(v4si x) {

     return x / (v4si) {3,3,3,3};
}


GCC generates the following assembler

ttt:
    movdqa    (%rcx), %xmm0
    movl    $1431655766, %ecx
    movd    %xmm0, %r8d
    pextrd    $1, %xmm0, %r10d
    pextrd    $2, %xmm0, %r11d
    movl    %r8d, %eax
    sarl    $31, %r8d
    imull    %ecx
    movl    %r10d, %eax
    sarl    $31, %r10d
    movl    %edx, %r9d
    imull    %ecx
    movl    %r11d, %eax
    subl    %r8d, %r9d
    sarl    $31, %r11d
    movl    %edx, %r8d
    imull    %ecx
    subl    %r10d, %r8d
    movl    %edx, %r10d
    subl    %r11d, %r10d
    pextrd    $3, %xmm0, %r11d
    movl    %r11d, %eax
    imull    %ecx
    sarl    $31, %r11d
    movd    %r10d, %xmm1
    movd    %r9d, %xmm0
    pinsrd    $0x1, %r8d, %xmm0
    subl    %r11d, %edx
    pinsrd    $0x1, %edx, %xmm1
    punpcklqdq    %xmm1, %xmm0
    ret


Thus gcc DOES optimize the division to be done through High Multiplication, but
it is applied to each value separately instead of vectorized ones. Assember
should look like


    movdqa    .LC190(%rip), %xmm0
    pmulld    (%rcx), %xmm0
    pslld    $31, %xmm0
    ret


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-07-02  7:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-12 12:45 [Bug c/53645] New: Missed optimization for division of vector types andrii.riabushenko at barclays dot com
2012-06-12 13:34 ` [Bug c/53645] " rguenth at gcc dot gnu.org
2012-06-12 13:37 ` [Bug tree-optimization/53645] Missed optimization for vector integer division lowering rguenth at gcc dot gnu.org
2012-06-12 18:34 ` jakub at gcc dot gnu.org
2012-06-12 20:55 ` pinskia at gcc dot gnu.org
2012-06-13  9:46 ` rguenth at gcc dot gnu.org
2012-06-27  8:50 ` jakub at gcc dot gnu.org
2012-06-28 11:38 ` jakub at gcc dot gnu.org
2012-06-28 12:34 ` jakub at gcc dot gnu.org
2012-06-28 17:53 ` jakub at gcc dot gnu.org
2012-07-01 10:24 ` ubizjak at gmail dot com
2012-07-02  6:56 ` jakub at gcc dot gnu.org
2012-07-02  7:00 ` jakub 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).