Page MenuHomePhabricator

[mlir][Vector] Fix vector.transfer alignment calculation

Authored by nicolasvasilache on May 28 2020, 9:04 AM.


Summary introduces alignment propagation for vector transfer operations. Unfortunately, the alignment calculation is incorrect and can result in crashes.

This revision fixes the calculation by using the natural alignment of the memref elemental type, instead of the resulting vector type.

If more alignment is desired, it can be done in 2 ways:

  1. use a proper vector.type_cast to transform a memref<axbxcxdxf32> into a memref<axbxvector<cxdxf32>> giving a natural alignment of vector<cxdxf32>
  2. add an alignment attribute to vector transfer operations and propagate it.

With this change the alignment in the relevant tests goes down from 128 to 4.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 28 2020, 9:04 AM

Thanks for the patch. On the application I'm working on, the longest vector type would be vector<?x4>, plus I use scalarize-masked-mem-intrin in my pipeline so the issue addressed in this patch was not encountered on my targets before.

ftynse accepted this revision.May 28 2020, 10:46 AM
This revision is now accepted and ready to land.May 28 2020, 10:46 AM
nicolasvasilache retitled this revision from [mlior][Vector] Fix vector.transfer alignment calculation to [mlir][Vector] Fix vector.transfer alignment calculation.May 28 2020, 2:49 PM

Add a VectorToSCF pass.

Drop spurious reformat.

This revision was automatically updated to reflect the committed changes.