This is an archive of the discontinued LLVM Phabricator instance.

[mlir][AMDGPU] Remove buffer ops that are statically out of bounds

Authored by krzysz00 on Nov 16 2022, 11:13 AM.



When the bounds check attribute is true, the raw buffer load, store,
and atomic operations have well-defined behavior (returning 0 for
loads and ignoring stores) when the buffer access exceeds the bounds
of the memory being accessed.

Because of how LLVM currently implements these buffer operations (as
opaque intrinsics), the backend cannot optimize out this known
behavior and eliminate the memory operations. Therefore, use MLIR's
canonicalization system to eliminate these operations.

Diff Detail

Event Timeline

krzysz00 created this revision.Nov 16 2022, 11:13 AM
krzysz00 requested review of this revision.Nov 16 2022, 11:13 AM
krzysz00 updated this revision to Diff 476240.Nov 17 2022, 2:22 PM

Dialect name changed

zero9178 added inline comments.Nov 17 2022, 2:27 PM

I believe you must also add the arithmetic dialect as a dependent dialect here, since the canonicalization now depends on it being loaded

krzysz00 updated this revision to Diff 476542.Nov 18 2022, 11:41 AM

Add dependentDialects, because that does need to be there.

krzysz00 marked an inline comment as done.Nov 18 2022, 11:42 AM
krzysz00 added inline comments.

Good tacch, thanks!

krzysz00 marked an inline comment as done.Nov 18 2022, 1:38 PM
nirvedhmeshram accepted this revision.Nov 18 2022, 2:00 PM

LGTM! just some minor nits.


nit: maybe this function can just return a bool so you dont have to use it with succeeded?

This revision is now accepted and ready to land.Nov 18 2022, 2:00 PM
nirvedhmeshram added inline comments.Nov 18 2022, 2:02 PM

Since llvm prefers early exits
maybe refactor to

  return failure();
return success();
krzysz00 updated this revision to Diff 476606.Nov 18 2022, 2:30 PM

Address review nits

This revision was landed with ongoing or failed builds.Nov 21 2022, 8:47 AM
This revision was automatically updated to reflect the committed changes.