-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[PowerPC] Lowering support for EVL type VP_LOAD/VP_STORE #165910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,10 @@ using namespace llvm; | |
|
|
||
| #define DEBUG_TYPE "ppctti" | ||
|
|
||
| static cl::opt<bool> Pwr9EVL("ppc-pwr9-evl", | ||
| cl::desc("Allow vp.load and vp.store for pwr9"), | ||
| cl::init(false), cl::Hidden); | ||
|
|
||
| static cl::opt<bool> VecMaskCost("ppc-vec-mask-cost", | ||
| cl::desc("add masking cost for i1 vectors"), cl::init(true), cl::Hidden); | ||
|
|
||
|
|
@@ -1031,3 +1035,42 @@ bool PPCTTIImpl::getTgtMemIntrinsic(IntrinsicInst *Inst, | |
| bool PPCTTIImpl::supportsTailCallFor(const CallBase *CB) const { | ||
| return TLI->supportsTailCallFor(CB); | ||
| } | ||
|
|
||
| // Target hook used by CodeGen to decide whether to expand vector predication | ||
| // intrinsics into scalar operations or to use special ISD nodes to represent | ||
| // them. The Target will not see the intrinsics. | ||
| TargetTransformInfo::VPLegalization | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good if you can add some documentation to summarize this new function. |
||
| PPCTTIImpl::getVPLegalizationStrategy(const VPIntrinsic &PI) const { | ||
| using VPLegalization = TargetTransformInfo::VPLegalization; | ||
| unsigned Directive = ST->getCPUDirective(); | ||
| VPLegalization DefaultLegalization = BaseT::getVPLegalizationStrategy(PI); | ||
| if (Directive != PPC::DIR_PWR10 && Directive != PPC::DIR_PWR_FUTURE && | ||
| (!Pwr9EVL || Directive != PPC::DIR_PWR9)) | ||
| return DefaultLegalization; | ||
|
|
||
| if (!ST->isPPC64()) | ||
| return DefaultLegalization; | ||
|
|
||
| unsigned IID = PI.getIntrinsicID(); | ||
| if (IID != Intrinsic::vp_load && IID != Intrinsic::vp_store) | ||
| return DefaultLegalization; | ||
|
|
||
| bool IsLoad = IID == Intrinsic::vp_load; | ||
| Type *VecTy = IsLoad ? PI.getType() : PI.getOperand(0)->getType(); | ||
| EVT VT = TLI->getValueType(DL, VecTy, true); | ||
| if (VT != MVT::v2i64 && VT != MVT::v4i32 && VT != MVT::v8i16 && | ||
| VT != MVT::v16i8) | ||
| return DefaultLegalization; | ||
|
|
||
| auto IsAllTrueMask = [](Value *MaskVal) { | ||
| if (Value *SplattedVal = getSplatValue(MaskVal)) | ||
| if (auto *ConstValue = dyn_cast<Constant>(SplattedVal)) | ||
| return ConstValue->isAllOnesValue(); | ||
| return false; | ||
| }; | ||
| unsigned MaskIx = IsLoad ? 1 : 2; | ||
| if (!IsAllTrueMask(PI.getOperand(MaskIx))) | ||
| return DefaultLegalization; | ||
|
|
||
| return VPLegalization(VPLegalization::Legal, VPLegalization::Legal); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | ||
| ; RUN: llc -verify-machineinstrs -mcpu=pwr10 \ | ||
| ; RUN: -mtriple=powerpc64le-unknown-unknown < %s | FileCheck %s | ||
| ; RUN: llc -verify-machineinstrs -mcpu=future \ | ||
| ; RUN: -mtriple=powerpc64le-unknown-unknown < %s | FileCheck -check-prefix=FUTURE %s | ||
|
|
||
| ; RUN: llc -verify-machineinstrs -mcpu=pwr10 \ | ||
| ; RUN: -mtriple=powerpc64-unknown-unknown < %s | FileCheck %s | ||
| ; RUN: llc -verify-machineinstrs -mcpu=future \ | ||
| ; RUN: -mtriple=powerpc64-unknown-unknown < %s | FileCheck --check-prefix=FUTURE %s | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define void @stxvl1(<16 x i8> %a, ptr %b, i64 %c) { | ||
| ; CHECK-LABEL: stxvl1: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 3, 6, 56 | ||
| ; CHECK-NEXT: stxvl 34, 5, 3 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: stxvl1: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: stxvrl 34, 5, 6 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %cconv = trunc i64 %c to i32 | ||
| tail call void @llvm.vp.store.v16i8.p0(<16 x i8> %a, ptr %b, <16 x i1> splat (i1 true), i32 %cconv) | ||
| ret void | ||
| } | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define void @stxvl2(<8 x i16> %a, ptr %b, i64 %c) { | ||
| ; CHECK-LABEL: stxvl2: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 3, 6, 57 | ||
| ; CHECK-NEXT: stxvl 34, 5, 3 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: stxvl2: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: sldi 3, 6, 1 | ||
| ; FUTURE-NEXT: stxvrl 34, 5, 3 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %cconv = trunc i64 %c to i32 | ||
| tail call void @llvm.vp.store.v8i16.p0(<8 x i16> %a, ptr %b, <8 x i1> splat (i1 true), i32 %cconv) | ||
| ret void | ||
| } | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define void @stxvl4(<4 x i32> %a, ptr %b, i64 %c) { | ||
| ; CHECK-LABEL: stxvl4: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 3, 6, 58 | ||
| ; CHECK-NEXT: stxvl 34, 5, 3 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: stxvl4: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: sldi 3, 6, 2 | ||
| ; FUTURE-NEXT: stxvrl 34, 5, 3 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %cconv = trunc i64 %c to i32 | ||
| tail call void @llvm.vp.store.v4i32.p0(<4 x i32> %a, ptr %b, <4 x i1> splat (i1 true), i32 %cconv) | ||
| ret void | ||
| } | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define void @stxvl8(<2 x i64> %a, ptr %b, i64 %c) { | ||
| ; CHECK-LABEL: stxvl8: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 3, 6, 59 | ||
| ; CHECK-NEXT: stxvl 34, 5, 3 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: stxvl8: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: sldi 3, 6, 3 | ||
| ; FUTURE-NEXT: stxvrl 34, 5, 3 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %cconv = trunc i64 %c to i32 | ||
| tail call void @llvm.vp.store.v2i64.p0(<2 x i64> %a, ptr %b, <2 x i1> splat (i1 true), i32 %cconv) | ||
| ret void | ||
| } | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define <16 x i8> @lxvl1(ptr %a, i64 %b) { | ||
| ; CHECK-LABEL: lxvl1: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 4, 4, 56 | ||
| ; CHECK-NEXT: lxvl 34, 3, 4 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: lxvl1: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: lxvrl 34, 3, 4 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %bconv = trunc i64 %b to i32 | ||
| %0 = tail call <16 x i8> @llvm.vp.load.v16i8.p0(ptr %a, <16 x i1> splat (i1 true), i32 %bconv) | ||
| ret <16 x i8> %0 | ||
| } | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define <8 x i16> @lxvl2(ptr %a, i64 %b) { | ||
| ; CHECK-LABEL: lxvl2: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 4, 4, 57 | ||
| ; CHECK-NEXT: lxvl 34, 3, 4 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: lxvl2: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: sldi 4, 4, 1 | ||
| ; FUTURE-NEXT: lxvrl 34, 3, 4 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %bconv = trunc i64 %b to i32 | ||
| %0 = tail call <8 x i16> @llvm.vp.load.v8i16.p0(ptr %a, <8 x i1> splat (i1 true), i32 %bconv) | ||
| ret <8 x i16> %0 | ||
| } | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define <4 x i32> @lxvl4(ptr %a, i64 %b) { | ||
| ; CHECK-LABEL: lxvl4: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 4, 4, 58 | ||
| ; CHECK-NEXT: lxvl 34, 3, 4 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: lxvl4: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: sldi 4, 4, 2 | ||
| ; FUTURE-NEXT: lxvrl 34, 3, 4 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %bconv = trunc i64 %b to i32 | ||
| %0 = tail call <4 x i32> @llvm.vp.load.v4i32.p0(ptr %a, <4 x i1> splat (i1 true), i32 %bconv) | ||
| ret <4 x i32> %0 | ||
| } | ||
|
|
||
| ; Function Attrs: nounwind readnone | ||
| define <2 x i64> @lxvl8(ptr %a, i64 %b) { | ||
| ; CHECK-LABEL: lxvl8: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: sldi 4, 4, 59 | ||
| ; CHECK-NEXT: lxvl 34, 3, 4 | ||
| ; CHECK-NEXT: blr | ||
| ; | ||
| ; FUTURE-LABEL: lxvl8: | ||
| ; FUTURE: # %bb.0: # %entry | ||
| ; FUTURE-NEXT: sldi 4, 4, 3 | ||
| ; FUTURE-NEXT: lxvrl 34, 3, 4 | ||
| ; FUTURE-NEXT: blr | ||
| entry: | ||
| %bconv = trunc i64 %b to i32 | ||
| %0 = tail call <2 x i64> @llvm.vp.load.v2i64.p0(ptr %a, <2 x i1> splat (i1 true), i32 %bconv) | ||
| ret <2 x i64> %0 | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add some doc on what this function's uses are.