This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Stop replace masked compressstore with normal masked store
ClosedPublic

Authored by xiangzhangllvm on Dec 8 2022, 4:53 PM.

Details

Summary

The masked compressstore can not be replaced with normal masked store.
Because masked compressstore required adjacently store the masked elements
which normal masked store can not make sure.

Diff Detail

Event Timeline

xiangzhangllvm created this revision.Dec 8 2022, 4:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2022, 4:53 PM
xiangzhangllvm requested review of this revision.Dec 8 2022, 4:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2022, 4:53 PM
pengfei added inline comments.Dec 9 2022, 1:48 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11033–11034

Do you mean cannot be a compress store?

pengfei added inline comments.Dec 9 2022, 1:52 AM
llvm/test/CodeGen/X86/masked_compressstore_isel.ll
15–17

Can we optimizate it to truncated compressstore?

xiangzhangllvm added inline comments.Dec 9 2022, 3:25 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11033–11034

Yes, right

llvm/test/CodeGen/X86/masked_compressstore_isel.ll
15–17

Do we have truncated compressstore?
May be can implement by targets.
But for target independent code we can not directly transfer to normal masted store.

pengfei added inline comments.Dec 9 2022, 4:56 AM
llvm/test/CodeGen/X86/masked_compressstore_isel.ll
15–17

I think the truncated xxx is just a code concept, it actually means turning the trunction from value to the mask.
So I think we should combine these 2 lines into VPCOMPRESSWZ256mrk ... just like mask store.

xiangzhangllvm added inline comments.Dec 11 2022, 6:04 PM
llvm/test/CodeGen/X86/masked_compressstore_isel.ll
15–17

Can we first let it in and then try do the optimization ?
I wish to close a must fix bug first. thanks!

pengfei accepted this revision.Dec 11 2022, 6:17 PM

LGTM.

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11033–11034

Don't forget update the comments.

llvm/test/CodeGen/X86/masked_compressstore_isel.ll
15–17

Sure. Better add a TODO in comments.

This revision is now accepted and ready to land.Dec 11 2022, 6:17 PM

LGTM.

Thank you! sure, let me add a todo here when commit.

This revision was landed with ongoing or failed builds.Dec 11 2022, 6:41 PM
This revision was automatically updated to reflect the committed changes.
pengfei added inline comments.Dec 11 2022, 7:13 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11033–11034

I meant the comment We can do this even if this is already a masked truncstore or a compress store is wrong. I'd expect it would be:

// If this is a TRUNC followed by a masked store, fold this into a masked
// truncating store.  We can do this even if this is already a masked
// truncstore.
// If this is a TRUNC followed by a compress store, we don't do the combine.
// TODO: Try combine to masked compress store if possiable.
xiangzhangllvm added inline comments.Dec 11 2022, 7:25 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
11033–11034

Good catch! Done in 7557d94bd8d92e486084074e1017eb33149f9156 , thanks again!