This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/63945] New: Missing vectorization optimization
- From: "bangerth at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 19 Nov 2014 02:34:21 +0000
- Subject: [Bug tree-optimization/63945] New: Missing vectorization optimization
- Auto-submitted: auto-generated
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();
}
...................................