https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61724
Bug ID: 61724
Summary: Some loops not vectorised
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: dzidzitop at vfemail dot net
Created attachment 33075
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33075&action=edit
Test code
Some loops inside C++ classes are not vectorised by the tree-vectorise driver.
Attached is an example. In it, the pairs {A::f(), A::h()} and {A::g(), A::k()}
are twins, with subtle differences in how they are implemented:
- A::f() uses condition on this->size; A::g() reads this->size into the
register variable n
- A::g() reads data from this->y (std::unique_ptr); A::k() copies the same
pointer to a local T * variable.
In both cases only the loop within the second pair member is vectorised.
Here is the compiler output.
$ g++ -std=c++11 -fPIC -O3 -ftree-vectorizer-verbose=6 test.cpp
Analyzing loop at test.cpp:44
44: versioning for alias required: can't determine dependence between
*D.24505_63 and *D.24502_62
44: mark for run-time aliasing test between *D.24505_63 and *D.24502_62
44: Vectorizing an unaligned access.
44: Vectorizing an unaligned access.
44: vect_model_load_cost: unaligned supported by hardware.
44: vect_model_load_cost: inside_cost = 2, outside_cost = 0 .
44: vect_model_store_cost: unaligned supported by hardware.
44: vect_model_store_cost: inside_cost = 2, outside_cost = 0 .
44: cost model: Adding cost of checks for loop versioning aliasing.
44: cost model: epilogue peel iters set to vf/2 because loop iterations are
unknown .
44: Cost model analysis:
Vector inside of loop cost: 4
Vector outside of loop cost: 26
Scalar iteration cost: 2
Scalar outside cost: 1
prologue iterations: 0
epilogue iterations: 8
Calculated minimum iters for profitability: 14
44: Profitability threshold = 15
Vectorizing loop at test.cpp:44
44: Profitability threshold is 15 loop iterations.
44: create runtime check for data references *D.24505_63 and *D.24502_62
44: created 1 versioning for alias checks.
44: LOOP VECTORIZED.
Analyzing loop at test.cpp:22
22: versioning for alias required: can't determine dependence between
*D.24457_38 and *D.24458_37
22: mark for run-time aliasing test between *D.24457_38 and *D.24458_37
22: Vectorizing an unaligned access.
22: Vectorizing an unaligned access.
22: vect_model_load_cost: unaligned supported by hardware.
22: vect_model_load_cost: inside_cost = 2, outside_cost = 0 .
22: vect_model_store_cost: unaligned supported by hardware.
22: vect_model_store_cost: inside_cost = 2, outside_cost = 0 .
22: cost model: Adding cost of checks for loop versioning aliasing.
22: cost model: epilogue peel iters set to vf/2 because loop iterations are
unknown .
22: Cost model analysis:
Vector inside of loop cost: 4
Vector outside of loop cost: 26
Scalar iteration cost: 2
Scalar outside cost: 1
prologue iterations: 0
epilogue iterations: 8
Calculated minimum iters for profitability: 14
22: Profitability threshold = 15
Vectorizing loop at test.cpp:22
22: Profitability threshold is 15 loop iterations.
22: create runtime check for data references *D.24457_38 and *D.24458_37
22: created 1 versioning for alias checks.
22: LOOP VECTORIZED.
Analyzing loop at test.cpp:34
34: not vectorized: not suitable for gather D.24489_53 = *D.24485_52;
Analyzing loop at test.cpp:12
12: not vectorized: number of iterations cannot be computed.
test.cpp:49: note: vectorized 2 loops in function.