public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/63945] New: Missing vectorization optimization
@ 2014-11-19  2:34 bangerth at gmail dot com
  0 siblings, 0 replies; only message in thread
From: bangerth at gmail dot com @ 2014-11-19  2:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63945

            Bug ID: 63945
           Summary: Missing vectorization optimization
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bangerth at gmail dot com

(Reporting this for Bruno Turcksin <bruno.turcksin@gmail.com>.)

The loop in the following testcase cannot be vectorized, we get the error:

note: not vectorized: latch block not empty.
note: bad loop form.

The reason is that val is a member of the class, is evaluated in the if, and is
used in the loop that should be vectorized. If these three conditions are
satisfied the loop cannot be vectorized.

...............................

#include <vector>

class TEST
{
  public :
    TEST();
    void test();

  private :
    const double val;
};

TEST::TEST()
  :
  val(2.)
{}

void TEST::test()
{
  const unsigned int n(1000);
  std::vector<double> a(n);
  std::vector<double> b(n);
  std::vector<double> c(n);

  for (unsigned int i=0; i<n; ++i)
  {
    a[i] = 1.;
    b[i] = 1.;
  }

  if (val<100.)
  {
#pragma omp simd
    for (unsigned int i=0; i<n; ++i)
      c[i] = val*a[i]+b[i];
  }
}
int main ()
{
  TEST a;
  a.test();
}
...................................


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-11-19  2:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-19  2:34 [Bug tree-optimization/63945] New: Missing vectorization optimization bangerth at gmail dot com

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).