public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61724] New: Some loops not vectorised
@ 2014-07-05 19:47 dzidzitop at vfemail dot net
  2014-07-05 19:49 ` [Bug tree-optimization/61724] " pinskia at gcc dot gnu.org
  2021-08-07  5:09 ` [Bug tree-optimization/61724] Some loops not vectorized pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: dzidzitop at vfemail dot net @ 2014-07-05 19:47 UTC (permalink / raw)
  To: gcc-bugs

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.


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

* [Bug tree-optimization/61724] Some loops not vectorised
  2014-07-05 19:47 [Bug tree-optimization/61724] New: Some loops not vectorised dzidzitop at vfemail dot net
@ 2014-07-05 19:49 ` pinskia at gcc dot gnu.org
  2021-08-07  5:09 ` [Bug tree-optimization/61724] Some loops not vectorized pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-07-05 19:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely aliasing is getting in the way.


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

* [Bug tree-optimization/61724] Some loops not vectorized
  2014-07-05 19:47 [Bug tree-optimization/61724] New: Some loops not vectorised dzidzitop at vfemail dot net
  2014-07-05 19:49 ` [Bug tree-optimization/61724] " pinskia at gcc dot gnu.org
@ 2021-08-07  5:09 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-07  5:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
/app/example.cpp:12:21: note:  LOOP VECTORIZED

/app/example.cpp:22:31: note:  LOOP VECTORIZED

That is A::f and A::h.

A::g and A::k are optimized away as the results were not used.

If I add some slight code to allow them not to be optimized away, we use
__builtin_memcpy instead.

So this is fixed.

I not even going to check when as this has been fixed a long time ago.

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-05 19:47 [Bug tree-optimization/61724] New: Some loops not vectorised dzidzitop at vfemail dot net
2014-07-05 19:49 ` [Bug tree-optimization/61724] " pinskia at gcc dot gnu.org
2021-08-07  5:09 ` [Bug tree-optimization/61724] Some loops not vectorized 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).