Page MenuHomePhabricator

[SLP] Stop counting cost of gather sequences with multiple uses
ClosedPublic

Authored by mssimpso on Mar 21 2018, 9:28 AM.

Details

Summary

When building the SLP tree, we look for reuse among the vectorized tree entries. However, each gather sequence is represented by a unique tree entry, even though the sequence may be identical to another one. This means, for example, that a gather sequence with two uses will be counted twice when computing the cost of the tree. We should only count the cost of the definition of a gather sequence rather than its uses. During code generation, the redundant gather sequences are emitted, but we optimize them away with CSE. So it looks like this problem just affects the cost model.

Diff Detail

Repository
rL LLVM

Event Timeline

mssimpso created this revision.Mar 21 2018, 9:28 AM

Here is the SLP tree of the added test case. The cost of the gather (%a, %b, %c, %d) is added twice, once per use, before this patch.

ABataev added inline comments.Mar 21 2018, 9:50 AM
lib/Transforms/Vectorize/SLPVectorizer.cpp
2476–2481 ↗(On Diff #139309)

I think you can use std::any_of

test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
1 ↗(On Diff #139309)
  1. Commit this test as a separate NFC patch with the current codegen and then update it to show changes.
  2. use utils/update_test_checks.py to generate test checks.
mssimpso updated this revision to Diff 139346.Mar 21 2018, 12:19 PM
mssimpso marked 2 inline comments as done.

Addressed Alexey's comments. Thanks!

This revision is now accepted and ready to land.Mar 22 2018, 6:13 AM
This revision was automatically updated to reflect the committed changes.