[Bug tree-optimization/84512] [8 Regression] Missed optimization: should be precalculated in compile-time
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84512 Richard Biener changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #3 from Richard Biener --- Fixed.
[Bug tree-optimization/84512] [8 Regression] Missed optimization: should be precalculated in compile-time
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84512 --- Comment #2 from Richard Biener --- Author: rguenth Date: Tue Feb 27 15:25:33 2018 New Revision: 258036 URL: https://gcc.gnu.org/viewcvs?rev=258036=gcc=rev Log: 2018-02-27 Richard BienerPR tree-optimization/84512 * tree-vect-loop.c (vect_compute_single_scalar_iteration_cost): Do not use the estimate returned from record_stmt_cost for the scalar iteration cost but sum properly using add_stmt_cost. * gcc.dg/tree-ssa/pr84512.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr84512.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vect-loop.c
[Bug tree-optimization/84512] [8 Regression] Missed optimization: should be precalculated in compile-time
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84512 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Version|tree-ssa|8.0 Keywords||missed-optimization Last reconfirmed||2018-02-27 Blocks||53947 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Ever confirmed|0 |1 Summary|Missed optimization: should |[8 Regression] Missed |be precalculated in |optimization: should be |compile-time|precalculated in ||compile-time Target Milestone|--- |8.0 --- Comment #1 from Richard Biener --- Confirmed. This is another case where we vectorize one loop but not the other and DOM doesn't handle removing vector loads against scalar stores. Later store-merging aggregates the stores but nothig performs CSE after it. The vectorizer decides that vectorizing the reduction is profitable while vectorizing the init is not: t.c:4:3: note: Cost model analysis: Vector inside of loop cost: 68 Vector prologue cost: 8 Vector epilogue cost: 128 Scalar iteration cost: 16 Scalar outside cost: 0 Vector outside cost: 136 prologue iterations: 0 epilogue iterations: 2 t.c:4:3: note: cost model: the vector iteration cost = 68 divided by the scalar iteration cost = 16 is greater or equal to the vectorization factor = 4. t.c:4:3: note: not vectorized: vectorization not profitable. With -fno-vect-cost-model we vectorize both loops and optimize the function like clang does. The issue with the cost model here is that for the scalar iteration cost we end up using builtin_vectorization_cost () while for the vector cost we use add_stmt_cost. Only the latter makes a difference between the different kind of operations. I have a patch. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations