This is an archive of the discontinued LLVM Phabricator instance.

[mlir][scf] Relax type requirement on for
ClosedPublic

Authored by jpienaar on Mar 3 2023, 4:55 PM.

Details

Summary

scf.for loop was restricted to only operate on Index type since
splitting out from affine.for. Relax requirement to allow for signless
integer types additionally. This allows specifying explicitly different
bitwidths for different loops as well as specialize from index to iN
while still using scf.for.

Diff Detail

Event Timeline

jpienaar created this revision.Mar 3 2023, 4:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 4:55 PM
jpienaar requested review of this revision.Mar 3 2023, 4:55 PM
ftynse added a subscriber: ftynse.Mar 4 2023, 12:18 AM

Do we need to also update the lowering to LLVM? It may assume type is always index and end up using a different bitwidth.

Mogball accepted this revision.Mar 4 2023, 2:11 AM

+1 to what Alex said, but otherwise LGT

This revision is now accepted and ready to land.Mar 4 2023, 2:11 AM

Do we need to also update the lowering to LLVM? It may assume type is always index and end up using a different bitwidth.

I checked the final assembly output and saw different outputs as I changed width here. But let me double check the code.

Do we need to also update the lowering to LLVM? It may assume type is always index and end up using a different bitwidth.

I checked the final assembly output and saw different outputs as I changed width here. But let me double check the code.

SCFToControlFlow.cpp is handling this by way of using type inference method (and the constraints added on ForOp here with matching element type)
SCFToGPU.cpp seems to be only operating on AffineForOp
SCFToSPIRV.cpp is handling this by explicit element type queries
VectorToGPU.cpp looks also not to depend on requiring index type

I see no other lowering from scf::ForOp conversion side.

jpienaar updated this revision to Diff 502432.Mar 5 2023, 6:53 AM

Fix formatting

This revision was automatically updated to reflect the committed changes.