This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Fix a propagation bug with transfer_read
ClosedPublic

Authored by qcolombet on Jun 5 2023, 5:49 AM.

Details

Summary

In the vector distribute patterns, we used to move
vector.transfer_reads out of vector.warp_execute_on_lane0s
irrespectively of how they were defined.

This could create transfer_read operations that would read values from
within the warpOp's body from outside of the body.
E.g.,

warpop {
  %defined_in_body
  %read = transfer_read %defined_in_body
  vector.yield %read
}

>

warpop {
  %defined_in_body
  vector.yield ...
}
// %defined_in_body is referenced outside of its scope.
%read = transfer_read %defined_in_body

The fix consists in checking that all the values feeding the new
transfer_read are defined outside of warpOp's body.

Note: We could do this check before creating any operation, but that would
mean knowing what affine::makeComposedAffineApply actually do. So the
current fix is a trade off of coupling the implementations of this
propagation and makeComposedAffineApply versus compile time.

Diff Detail

Event Timeline

qcolombet created this revision.Jun 5 2023, 5:49 AM
Herald added a project: Restricted Project. · View Herald Transcript
qcolombet requested review of this revision.Jun 5 2023, 5:49 AM
nicolasvasilache accepted this revision.Jun 5 2023, 5:51 AM
This revision is now accepted and ready to land.Jun 5 2023, 5:51 AM
This revision was automatically updated to reflect the committed changes.