This is an archive of the discontinued LLVM Phabricator instance.

[DSE] Make sure that DSE+MSSA can handle masked stores
ClosedPublic

Authored by kparzysz on Sep 9 2020, 1:26 PM.

Details

Summary

Make changes to the MSSA-based parts of DSE to recognize and handle masked stores.

Diff Detail

Event Timeline

kparzysz created this revision.Sep 9 2020, 1:26 PM
kparzysz requested review of this revision.Sep 9 2020, 1:26 PM

I think that the isMaskedStoreOverwrite could be merged into isOverwrite, but it'd need to take instructions in addition to the locations. I think it would be a bit cleaner than what this patch does.

kparzysz updated this revision to Diff 290821.Sep 9 2020, 1:45 PM

Calling isMaskedStoreOverwrite from isOverwrite to avoid multiple checks.

Fixed a bug in ordering of NI and SI in the previous diff.

fhahn added inline comments.Sep 9 2020, 2:56 PM
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
412

Might be good to state that Later must overwrite Earlier. We could check that the mask of Later is a superset of the mask of Earlier. Might be good to add a TODO.

424

Wouldn't it be better to check if the pointers are must-alias?

1720–1721

Could you update the doc-comment?

1836

Is it possible to mark masked_store as IntrWriteMem? Then mayReadFromMemory should automatically return false for it.

kparzysz marked an inline comment as done.Sep 9 2020, 3:29 PM

Marked masked-storing intrinsics as write-only in 8b7c8f2c549d301fcea75d8e6e98a8ee160d5ff4.

kparzysz updated this revision to Diff 290839.Sep 9 2020, 3:49 PM

Addressed comments.

kparzysz marked 3 inline comments as done.Sep 9 2020, 3:49 PM
fhahn accepted this revision.Sep 11 2020, 6:56 AM

LGTM, thanks!

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1848

unrelated change?

This revision is now accepted and ready to land.Sep 11 2020, 6:56 AM
kparzysz added inline comments.Sep 11 2020, 7:20 AM
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
1848

Leftover from the "mayReadFromMemory" function from the previous diff. I'll remove it before committing.

This revision was landed with ongoing or failed builds.Sep 11 2020, 8:00 AM
This revision was automatically updated to reflect the committed changes.