This is an archive of the discontinued LLVM Phabricator instance.

[X86] getAVX512Node() - find constant broadcasts to encourage load-folding
ClosedPublic

Authored by RKSimon on Nov 14 2021, 6:38 AM.

Details

Summary

If an operand is a bitcasted or widended constant, try to more aggressively create broadcastable constants for folding, which in particular helps non-VLX modes.

I've refactored getAVX512Node so that VLX targets can make better use of this as well.

NOTE: In the future, I think we should consider removing the broadcast of constant data from DAG entirely and move this to either X86InstrInfo::foldMemoryOperand or a new pass - AVX1/2 targets has similar problems with missed (whole vector) folds that need to be improved as well.

Diff Detail

Event Timeline

RKSimon created this revision.Nov 14 2021, 6:38 AM
RKSimon requested review of this revision.Nov 14 2021, 6:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 14 2021, 6:38 AM
lebedev.ri added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
6442–6451

I do not understand, is this the right diff?

RKSimon added inline comments.Nov 14 2021, 7:58 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
6442–6451

autostash failed me :( - will rebase

pengfei added inline comments.Nov 14 2021, 10:38 PM
llvm/lib/Target/X86/X86ISelLowering.cpp
46230

Can we handle no-pow-2 type?

RKSimon added inline comments.Nov 15 2021, 1:27 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
46230

If we did see those cases I'd expect the ternlog code would already have crashed, but I'll add it to be sure.

RKSimon added inline comments.Nov 15 2021, 1:52 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
46230

Confirmed - canonicalizeBitSelect get called only after legalize ops, so the types will be legal and pow2

pengfei accepted this revision.Nov 15 2021, 4:25 AM

LGTM.

llvm/lib/Target/X86/X86ISelLowering.cpp
6423

No need parentheses?

46230

So we can assert (EltSizeInBits % 8) == 0?

This revision is now accepted and ready to land.Nov 15 2021, 4:25 AM