This is an archive of the discontinued LLVM Phabricator instance.

[VectorComine] Restrict single-element-store index to inbounds constant
ClosedPublic

Authored by qiucf on May 9 2021, 7:50 PM.

Details

Summary

As @nlopes illustrated in rG2db4979, we need to restrict the index to known inbounds constant otherwise the transformation is incorrect.

Diff Detail

Event Timeline

qiucf created this revision.May 9 2021, 7:50 PM
qiucf requested review of this revision.May 9 2021, 7:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2021, 7:50 PM
fhahn accepted this revision.May 10 2021, 5:01 AM

LGTM thanks! A but unfortunate the restriction is required, but there’s a few things we can do to improve things, like using ValueTracking to check whether a variable index is in range. But that can be a follow up

llvm/lib/Transforms/Vectorize/VectorCombine.cpp
805

I think it would be good to update the comment above to reflect all the conditions we check.

llvm/test/Transforms/VectorCombine/load-insert-store.ll
35

Could you add a test for scalable vectors?

This revision is now accepted and ready to land.May 10 2021, 5:01 AM
fhahn added a comment.May 11 2021, 2:43 PM

@qiucf it would be good to land this soon I think, otherwise I'll probably revert the original patch tomorrow and you can re-land the patch with the fix.

This revision was landed with ongoing or failed builds.May 11 2021, 10:21 PM
This revision was automatically updated to reflect the committed changes.
fhahn added a comment.May 14 2021, 4:11 AM

I think we should be able to also do this transform for variable indices, if we can prove they are valid, e.g. via constant range info. I put up D102476