This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Implement storeOfVectorConstantIsCheap hook to prevent store merging at VL=2
ClosedPublic

Authored by reames on May 17 2023, 10:10 AM.

Details

Summary

In general, VL=2 vectors are very questionable profitability wise. For constants specifically, our inability to materialize many vector constants cheaply biases us strongly towards unprofitability at VL=2.

This hook is very close to the x86 implementation. The difference is that X86 whitelists stores of zeros, and we're better off letting that stay scalar at VL=2.

Diff Detail

Event Timeline

reames created this revision.May 17 2023, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 10:10 AM
reames requested review of this revision.May 17 2023, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2023, 10:10 AM
craig.topper added inline comments.May 17 2023, 10:42 AM
llvm/lib/Target/RISCV/RISCVISelLowering.h
538

I notice X86 uses > 2 and your patch description talks about VL=2 and mentions being similar to X86, but you've used 4 here. Is 3 supported by store merging?

reames added inline comments.May 17 2023, 10:46 AM
llvm/lib/Target/RISCV/RISCVISelLowering.h
538

All the 3 x N types are illegal, and thus not candidates for store merging.

I mostly used 4 here as a bit of future proofing in case we decided to make odd types legal via the VP lowering which got some discussion recently. I'm not sure that we wouldn't want VL=3 to be formed in that case, but I figured it was better not to and then revisit if desired. (All of the cases I have where odd types would be profitable are VL=6. Yes, all of them.)

This revision is now accepted and ready to land.May 17 2023, 11:05 AM
This revision was landed with ongoing or failed builds.May 17 2023, 11:14 AM
This revision was automatically updated to reflect the committed changes.