[PATCH] D109296: [LV] Improve inclusivity of vectorization
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 6 10:58:15 PDT 2021
lebedev.ri added a comment.
I have figured out what was bothering me about counting checks - we are actually counting check *groups*,
where each group intentionally doesn't nessesairly contain only a single pointer, so the current design
doesn't account for the min/max reduction of pointers within group.
Collected some more numbers (sheet updated) (+ rawtherapee, babl/geg/, vanilla llvm test-suite).
I think it showcases the problem quite well. We currently are okay with vectorizing
if that means emitting a check with checks=8,members=45,RTCost=146,
but not with checks=9,members=18,RTCost=36.
I think the latter check is obviously cheaper than the former one :)
Those are real-world occurrences, not synthetic numbers.
One important epiphany occurred to me: with whatever formula we come up with,
it should not contain VF or cost of vectorized loop body,
because we'll pick threshold for vectorization using e.g. VF=8/AVX2,
but that will naturally result in smaller budget for checks
when LV will pick e.g VF=4/SSE4.2 as the best strategy.
As it stands right now, i think we roughly have 3 possible solutions:
1. "it ain't broken, let's not fix it." i think it's pretty obviously broken.
2. instead of counting the number of groups, count the total number of members. We could do that, but is not guaranteed to correlate with the final cost of checks, see RuntimeCheckingPtrGroup::addPointer() <https://github.com/llvm/llvm-project/blob/6d753b0751b1f4b6fb6851b69627244722c57a64/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L292-L319> I don't think this is the right fix
3. Just hardcode the budget. Might be a better approach than what we do now. I think then it should be ~`160`.
4. My original proposal. Specify the budget in terms of the number of scalar loop iterations. I think then it should be ~`12`.
5. ??? Does anyone have better idea?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109296/new/
https://reviews.llvm.org/D109296
More information about the llvm-commits
mailing list