This is an archive of the discontinued LLVM Phabricator instance.

[WIP] Teach instcombine how to destroy vector GEPs/loads/stores
AbandonedPublic

Authored by reames on Jan 23 2019, 10:20 PM.

Details

Reviewers
None
Summary

This is being used as a "meta review". Actual patches are linked below. What's in this diff is pieces which need to be split out and reviewed individually once the core infrastructure has landed.

Landed:

  • D57177 Demanded elements support for vector GEPs
  • D57398 SimplifyDemandedVectorElts for all intrinsics
  • D57247 Simply operands of masked stores and scatters based on demanded elements
  • D57372 Demanded elements support for masked.load and masked.gather
  • D57468 Strengthen handling of GEPs and generic calls for all undef lanes

Diff Detail

Event Timeline

reames created this revision.Jan 23 2019, 10:20 PM
reames updated this revision to Diff 183253.Jan 23 2019, 10:46 PM

Another possible transform. Probably in addition to, not in place of vector->scalar+broadcast transform which still needs written.

Decided to start from the demanded elements and work my way up to actual transforms. First two reviews are posted:

  • D57177 Demanded elements support for vector GEPs
  • D57247 Simply operands of masked stores and scatters based on demanded elements

Next up is to do the demanded bits for scatter and masked.load. After that, I should probably do expandload and compressedstore for completeness, though that may be done later since I've never seen their use.

Once that part is in, I'll return to the transforms for the individual instructions. Mostly as a reminder to self, the patterns of interest for each memory instruction are: splat of each operand, single element active, incrementing addresses, and inferring inactive lanes from undef. For GEPs, the main ones are scalarizing operands, scalarizing the instruction as a whole, and undef/demanded elt intersection.

The more general building blocks needed for the above discovered so far are:

  • Improved splat detection
  • Scalar masked store creation utilities
  • Horizontal op folding (e.g. or reduce over a mask vector)
  • Mask analysis utilities

Just to set expectations appropriately, I'm not promising to see all of the above through. I intend of making improvements until I stop seeing practical test cases which look painful, and that's about it. Anyone who wants to pick of a piece is very welcome to. :)

reames edited the summary of this revision. (Show Details)Jan 28 2019, 10:14 PM
reames edited the summary of this revision. (Show Details)Jan 29 2019, 10:33 AM
reames retitled this revision from [WIP] Teach instcombine how to destroy vector GEPs to [WIP] Teach instcombine how to destroy vector GEPs/loads/stores.
reames edited the summary of this revision. (Show Details)
reames edited the summary of this revision. (Show Details)Jan 30 2019, 12:58 PM
reames edited the summary of this revision. (Show Details)Mar 20 2019, 1:36 PM
reames abandoned this revision.Apr 19 2019, 12:06 PM

Most of the todos have been checked in, and not an area of current focus. Likely to still post a patch here or there, but they'll be able to stand on their own now that the frameworks in place.