https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123225
--- Comment #19 from Victor Do Nascimento <victorldn at gcc dot gnu.org> --- (In reply to Tamar Christina from comment #14) > Those numbers don't add up to me. The Adv. SIMD loop above has a scalar > iteration cost of 5 and the vector of 10. > So the loop in your example will be profitable with the "no more than 2 > scalar iteration costs". That's' not quite the case. Referring back to my Comment #6, with a scalar iteration cost of 5 and a vector iteration cost of 10, using the 2 scalar iteration costs threshold means this loop is nowhere near profitable. Bear in mind that I mentioned using the `min_profitable_estimate' value when contemplating the "the no more than 2 scalar iteration costs" statement. Because this takes into account the "outside cost" of both scalar and vector code, the math works out as follows on my machine choosing VF = 4 (the costing is slightly different for the target I'm compiling for): Vector inside of loop cost: 12 Vector prologue cost: 22 Vector epilogue cost: 14 Scalar iteration cost: 6 Scalar outside cost: 3 Vector outside cost: 36 prologue iterations: 2 epilogue iterations: 2 Calculated minimum iters for profitability: 8 So I like this approach because it takes into account both prologue and epilogue costs already. Therefore when Tamar's change comes in elidinig the epilogue, the cost-based acceptance rejection criterion won't need to be tweaked, we'll just see `Vector epilogue cost' reduced to 0 in many cases and `Calculated minimum iters for profitability' reduced accordingly. Then, if this value is less than or equal to 2 or some other number, we can allow vectorization to proceed.
