This is an archive of the discontinued LLVM Phabricator instance.

[mlir][StandardToSPIRV] Use spv.UMod for index re-calculation
ClosedPublic

Authored by antiagainst on Jul 13 2020, 1:23 PM.

Details

Summary

Per Vulkan's SPIR-V environment spec: "While the OpSRem and OpSMod
instructions are supported by the Vulkan environment, they require
non-negative values and thus do not enable additional functionality
beyond what OpUMod provides."

The getOffsetForBitwidth function is used for lowering std.load
and std.store, whose indices are of index type and cannot be
negative. So we should be okay to use spv.UMod directly here to
be exact. Also made the comment explicit about the assumption.

Diff Detail

Event Timeline

antiagainst created this revision.Jul 13 2020, 1:23 PM
ThomasRaoux accepted this revision.Jul 13 2020, 1:26 PM
This revision is now accepted and ready to land.Jul 13 2020, 1:26 PM
hanchung accepted this revision.Jul 14 2020, 8:21 AM
hanchung added inline comments.
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
130–133

Is it intended to add a "blank line" before and after l.131?

antiagainst added inline comments.Aug 5 2020, 11:47 AM
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
130–133

Yes. The former is explaining parameters why the latter is explaining what this function is doing. This is a minor thing though. :)