Open dc81c6b5-3a5b-438e-b826-9e7edb3cf487 opened 7 years ago
Great suggestion! We already report something like this for the inliner but not for the vectorizer.
I think I mentioned this on IRC but we have some other facilities around opt remarks that you might find useful (and provide feedback on ;). See my dev meeting talk (http://llvm.org/devmtg/2016-11/#talk15).
Great idea. We should add the predicted-speedups to our vectorizer's optimization remarks.
Extended Description
When running the Intel Compiler with -qopt-report=4, say, you get told the expected performance gain from vectorisation, amongst other useful information. For example,
LOOP BEGIN at permanent-in-c.c(47,7) remark #25045: Fused Loops: ( 47 50 )
LOOP END
gcc also gives you similar if perhaps less useful information.
[...] vect_model_reduction_cost: inside_cost = 6, prologue_cost = 2, epilogue_cost = 6 . test2.c:50:9: note: ==> examining statement: j_73 = j_186 + 1; test2.c:50:9: note: irrelevant. test2.c:50:9: note: ==> examining statement: if (j_73 < n.2_201) test2.c:50:9: note: irrelevant. test2.c:50:9: note: === vect_update_slp_costs_according_to_vf === test2.c:50:9: note: cost model: epilogue peel iters set to vf/2 because loop iterations are unknown . test2.c:50:9: note: Cost model analysis: Vector inside of loop cost: 50 Vector prologue cost: 8 Vector epilogue cost: 52 Scalar iteration cost: 20 Scalar outside cost: 4 Vector outside cost: 60 prologue iterations: 0 epilogue iterations: 2 Calculated minimum iters for profitability: 5 test2.c:50:9: note: Runtime profitability threshold = 4 test2.c:50:9: note: Static estimate profitability threshold = 4 test2.c:50:9: note: epilog loop required
[...]
It would be great if clang/llvm could provide similar information to the user/coder.