This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SelectionDAG] Refactor to support more scalable vector extending stores
ClosedPublic

Authored by Allen on Apr 9 2022, 3:12 AM.

Details

Summary

Similar to D122281, we should firstly exclude all scalable vector extending
stores and then selectively enable those which we directly support.

Also merge integer and float scalable vector into scalable_vector_valuetypes.

Diff Detail

Event Timeline

Allen created this revision.Apr 9 2022, 3:12 AM
Allen requested review of this revision.Apr 9 2022, 3:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2022, 3:12 AM
Allen updated this revision to Diff 421760.Apr 9 2022, 7:41 PM
paulwalker-arm added inline comments.Apr 10 2022, 5:46 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
1184–1185

Now that we have full coverage, can these iterators be changed to scalable_vector_valuetypes and the above fp_scalable_vector_valuetypes based loop be deleted?

Allen updated this revision to Diff 421816.Apr 10 2022, 6:34 PM
Allen edited the summary of this revision. (Show Details)

Merge integer_scalable_vector_valuetypes and fp_scalable_vector_valuetypes into scalable_vector_valuetypes

paulwalker-arm added inline comments.Apr 11 2022, 3:27 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7780 ↗(On Diff #421816)

Thanks for the change @Allen. Before accepting I just wanted to query this line. What's the circumstance where it now triggers? (I tried llvm-lit -v ../llvm-project/llvm/test/CodeGen/AArch64 without this change and nothing jumped out) I ask because it's not immediate clear to me that the callers are happy for the scalarisation request to be ignored, hence the original error message.

Allen marked 2 inline comments as done.Apr 14 2022, 8:10 AM

ping?


钟云德 Zhong Yunde
Mobile: +86-50000036116(For Welink,eSpace Calls)
Email: zhongyunde@huawei.com

发件人:Paul Walker via Phabricator <reviews@reviews.llvm.org>
收件人:Zhongyunde <zhongyunde@huawei.com>;paul.walker <paul.walker@arm.com>;david.sherwood <david.sherwood@arm.com>;efriedma <efriedma@quicinc.com>
抄 送:alextsao1999 <alextsao1999@outlook.com>;llvm-commits <llvm-commits@lists.llvm.org>;kristof.beyls <kristof.beyls@arm.com>;ecnelises <ecnelises@outlook.com>;acmerzhangxipeng <acmerzhangxipeng@163.com>;bhuvanendra.kumarn <bhuvanendra.kumarn@amd.com>;wangyihansh <wangyihansh@outlook.com>;yanliang.mu <yanliang.mu@intel.com>;aeubanks <aeubanks@google.com>;dougpuob <dougpuob@gmail.com>;michael.hliao <michael.hliao@gmail.com>;mcrosier <mcrosier@codeaurora.org>;jun.l <jun.l@samsung.com>;diana.picus <diana.picus@linaro.org>;flo <flo@fhahn.net>;david.green <david.green@arm.com>;simon.moll <simon.moll@emea.nec.com>;ruiling.song <ruiling.song@amd.com>;caroline.concatto <caroline.concatto@arm.com>
时 间:2022-04-11 18:28:13
主 题:[PATCH] D123449: [AArch64][SelectionDAG] Refactor to support more scalable vector extending stores

paulwalker-arm added inline comments.

Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:7780

if (StVT.isScalableVector())
  • report_fatal_error("Cannot scalarize scalable vector stores");

Thanks for the change @Allen. Before accepting I just wanted to query this line. What's the circumstance where it now triggers? (I tried llvm-lit -v ../llvm-project/llvm/test/CodeGen/AArch64 without this change and nothing jumped out) I ask because it's not immediate clear to me that the callers are happy for the scalarisation request to be ignored, hence the original error message.

CHANGES SINCE LAST ACTION

https://reviews.llvm.org/D123449/new/

https://reviews.llvm.org/D123449

Hi @Allen , I think you've missed my previous comment, which is the only thing stopping me from accepting the patch.

Allen added a comment.Apr 14 2022, 9:56 AM

Hi @Allen , I think you've missed my previous comment, which is the only thing stopping me from accepting the patch.

hi @paulwalker-arm,I'm sorry to miss that.
If we revert the following change, then we'll have 5 fail cases. I think none of them are Legal should also be work, as we pick them out are taken into account of the performance.

+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1214,12 +1214,6 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,

}
 
// Then, selectively enable those which we directly support.
  • setTruncStoreAction(MVT::nxv2i64, MVT::nxv2i8, Legal);
  • setTruncStoreAction(MVT::nxv2i64, MVT::nxv2i16, Legal);
  • setTruncStoreAction(MVT::nxv2i64, MVT::nxv2i32, Legal);
  • setTruncStoreAction(MVT::nxv4i32, MVT::nxv4i8, Legal);
  • setTruncStoreAction(MVT::nxv4i32, MVT::nxv4i16, Legal);
  • setTruncStoreAction(MVT::nxv8i16, MVT::nxv8i8, Legal);

the related failed cases

LLVM :: CodeGen/AArch64/spillfill-sve.ll
LLVM :: CodeGen/AArch64/sve-forward-st-to-ld.ll
LLVM :: CodeGen/AArch64/sve-split-store.ll
LLVM :: CodeGen/AArch64/sve-st1-addressing-mode-reg-reg.ll
LLVM :: CodeGen/AArch64/sve-trunc.ll

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7780 ↗(On Diff #421816)

hi @paulwalker-arm,If we revert the following change, then we'll have 5 fail cases. I think none of them are Legal should also be work, as we pick them out are taken into account of the performance.

+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1214,12 +1214,6 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
     }
 
     // Then, selectively enable those which we directly support.
-    setTruncStoreAction(MVT::nxv2i64, MVT::nxv2i8, Legal);
-    setTruncStoreAction(MVT::nxv2i64, MVT::nxv2i16, Legal);
-    setTruncStoreAction(MVT::nxv2i64, MVT::nxv2i32, Legal);
-    setTruncStoreAction(MVT::nxv4i32, MVT::nxv4i8, Legal);
-    setTruncStoreAction(MVT::nxv4i32, MVT::nxv4i16, Legal);
-    setTruncStoreAction(MVT::nxv8i16, MVT::nxv8i8, Legal);

the related failed cases

LLVM :: CodeGen/AArch64/spillfill-sve.ll
 LLVM :: CodeGen/AArch64/sve-forward-st-to-ld.ll
 LLVM :: CodeGen/AArch64/sve-split-store.ll
 LLVM :: CodeGen/AArch64/sve-st1-addressing-mode-reg-reg.ll
 LLVM :: CodeGen/AArch64/sve-trunc.ll
7780 ↗(On Diff #421816)

@paulwalker-arm, need I revert this line's change ?

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
1184–1185

Apply you review, thanks!

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7780 ↗(On Diff #421816)

Your setTruncStoreAction related changes are fine. I'm specifically only talking about the single line report_fatal_error("Cannot scalarize scalable vector stores");-> return SDValue(); change. This looks unnecessary and potentially wrong. If I try this patch but with the report_fatal_error left intact I do not see any test failures.

Allen added inline comments.Apr 14 2022, 10:33 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7780 ↗(On Diff #421816)

sorry, may be I don't express clear!

I mean that, If I only keep the changes of setTruncStoreAction(VT, InnerVT, Expand) , but without picking out the ones, which are legal, then it will crash at report_fatal_error with above 5 test cases.
So I change report_fatal_error("Cannot scalarize scalable vector stores") into return SDValue() to avoid it.

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7780 ↗(On Diff #421816)

I see, thanks for explaining. I believe in that case the report_fatal_error is correct behaviour. Essentially the code generator has got itself into a state where is needs to scalarise the trunc store (created artificially by pretending we don't support any trunc stores), but scalarisation is not possible with scalable vectors and so we report the error.

If there's a bug then the fix is more likely to be to prevent the call to scalarizeVectorStore. But that's not something you need to worry about for this patch, if at all, because we do support trunc stores.

Matt added a subscriber: Matt.Apr 14 2022, 2:05 PM
Allen updated this revision to Diff 422992.Apr 14 2022, 6:47 PM

revert the change of report_fatal_error("Cannot scalarize scalable vector stores") as we do support trunc stores

Allen marked an inline comment as done.Apr 14 2022, 6:51 PM
Allen added inline comments.
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
7780 ↗(On Diff #421816)

thanks very much, I revert the change as you said, we do support trunc stores.

paulwalker-arm accepted this revision.Apr 15 2022, 2:26 AM
This revision is now accepted and ready to land.Apr 15 2022, 2:26 AM
This revision was landed with ongoing or failed builds.Apr 15 2022, 4:12 AM
This revision was automatically updated to reflect the committed changes.
Allen marked an inline comment as done.