From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14555 invoked by alias); 13 Jul 2011 10:43:52 -0000 Received: (qmail 14546 invoked by uid 22791); 13 Jul 2011 10:43:52 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Jul 2011 10:43:16 +0000 From: "vincenzo.innocente at cern dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49730] New: loop not vectorized if inside another loop X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vincenzo.innocente at cern dot ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 13 Jul 2011 10:43:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg00984.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49730 Summary: loop not vectorized if inside another loop Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: vincenzo.innocente@cern.ch I've this simple double loop (used in benchmark) the inner loop (sloop) is not vectorized when invoked inside the longer loop (dloop) c++ -Ofast -c vectdloop.cc -ftree-vectorizer-verbose=7 vectdloop.cc:9: note: Profitability threshold = 6 vectdloop.cc:9: note: Profitability threshold is 6 loop iterations. vectdloop.cc:9: note: LOOP VECTORIZED. vectdloop.cc:7: note: vectorized 1 loops in function. vectdloop.cc:20: note: not vectorized: unexpected loop form. vectdloop.cc:16: note: vectorized 0 loops in function. #include inline float fn(float x) { return 2.f*x+std::sqrt(x); } void sloop(float * __restrict__ s, float const * __restrict__ xx) { const int ls=16; for (int j=0; j < ls; ++j) { s[j] = fn(xx[j]); } } int dloop(float yyy) { int niter = 100000; float x = 0.5f; yyy=0; const int ls=16; for (int i=0; i < niter; ++i) { float s[ls]; float xx[ls]; for (int j=0; j < ls; ++j) xx[j] =x+(5*(j&1)); sloop(s,xx); // for (int j=0; j < ls; ++j) s[j] = fn(xx[j]); x += 1e-6f; for (int j=0; j < ls; ++j) yyy+=s[j]; } if (yyy == 2.32132323232f) niter--; return niter; }