This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Disable SLP vectorization by default due to unresolved profitability issues
ClosedPublic

Authored by reames on Aug 25 2022, 10:48 AM.

Details

Summary

This change implements a TTI query with the goal of disabling slp vectorization on RISCV. The current default configuration disables SLP already, but its current tied to the ability to lower fixed length vectors. Over in D131508, I want to enable fixed length vectors for purposes of LoopVectorizer, but preliminary analysis has revealed a couple of SLP specific issues we need to resolve before enabling it by default. This change exists to allow us to enable LV without SLP.

The major issues for SLP/RISCV I currently know of are:

  • We have a cost modeling problem for vector constants. SLP mostly ignores the cost of materializing constants, and on most targets that works out mostly okay. RISCV has unusually expensive constant materialization for large constants, so we end up with common patterns (e.g. initializing adjacent unsigned fields with constants) being unprofitably vectorized. Work on this started under D126885, and there is ongoing discussion on follow ups there.
  • We will vectorize sub-word parallel operations and don't have robust lowering support to re-scalarize. Consider a pair of i32 stores which could be vectorized as <2 x i32> or could be done as a single i64 store. The later is likely more profitable, but not what we currently generate. I have not fully dug into why yet.

Note that both of these issues could exist for LV in theory, but are significantly less likely. LV is strongly biased towards constant splats and longer vectors. Splats are significantly cheaper to lower (as a class), and longer vectors allows fixed cost errors to be amortized across more elements.

Diff Detail

Event Timeline

reames created this revision.Aug 25 2022, 10:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2022, 10:48 AM
reames requested review of this revision.Aug 25 2022, 10:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2022, 10:48 AM
This revision is now accepted and ready to land.Aug 26 2022, 12:28 PM
This revision was landed with ongoing or failed builds.Aug 26 2022, 2:12 PM
This revision was automatically updated to reflect the committed changes.