public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/51499] New: vectorizer missing simple case
@ 2011-12-10 18:39 fb.programming at gmail dot com
  2011-12-11  8:29 ` [Bug tree-optimization/51499] " irar at il dot ibm.com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: fb.programming at gmail dot com @ 2011-12-10 18:39 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51499
           Summary: vectorizer missing simple case
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: fb.programming@gmail.com


The sse vectorizer seems to miss one of the simplest cases:

#include <cstdio>
#include <cstdlib>

double loop(double a, size_t n){
   // initialise differently so compiler doesn't simplify
   double sum1=0.1, sum2=0.2, sum3=0.3, sum4=0.4, sum5=0.5, sum6=0.6;
   for(size_t i=0; i<n; i++){
      sum1+=a; sum2+=a; sum3+=a; sum4+=a; sum5+=a; sum6+=a;
   }
   return sum1+sum2+sum3+sum4+sum5+sum6-2.1-6.0*a*n;
}

int main(int argc, char** argv) {
   size_t n=1000000;
   double a=1.1;
   printf("res=%f\n", loop(a,n));
   return EXIT_SUCCESS;
}

g++-4.6.2 -Wall -O2 -ftree-vectorize -ftree-vectorizer-verbose=2 test.cpp

test.cpp:7: note: not vectorized: unsupported use in stmt.
test.cpp:4: note: vectorized 0 loops in function.

We get six addsd operations - whereas an optimisation should have
given us three addpd operations.

.L3:
    addq    $1, %rax
    addsd    %xmm0, %xmm6
    cmpq    %rdi, %rax
    addsd    %xmm0, %xmm5
    addsd    %xmm0, %xmm4
    addsd    %xmm0, %xmm3
    addsd    %xmm0, %xmm2
    addsd    %xmm0, %xmm1
    jne    .L3


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

end of thread, other threads:[~2021-08-07  5:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-10 18:39 [Bug tree-optimization/51499] New: vectorizer missing simple case fb.programming at gmail dot com
2011-12-11  8:29 ` [Bug tree-optimization/51499] " irar at il dot ibm.com
2011-12-11  8:48 ` fb.programming at gmail dot com
2011-12-11  9:05 ` irar at il dot ibm.com
2011-12-11 12:13 ` fb.programming at gmail dot com
2011-12-11 13:39 ` irar at il dot ibm.com
2011-12-11 14:55 ` dominiq at lps dot ens.fr
2011-12-11 16:58 ` fb.programming at gmail dot com
2011-12-12 11:13 ` irar at il dot ibm.com
2011-12-12 11:23 ` irar at il dot ibm.com
2011-12-12 11:27 ` rguenth at gcc dot gnu.org
2011-12-12 12:21 ` irar at il dot ibm.com
2011-12-12 13:10 ` dominiq at lps dot ens.fr
2011-12-12 14:31 ` fb.programming at gmail dot com
2011-12-13 16:33 ` irar at il dot ibm.com
2021-08-07  5:19 ` [Bug tree-optimization/51499] -Ofast does not vectorize while -O3 does 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).