llvm-project/llvm/test/Transforms
Cullen Rhodes 1e7efd397a [LV] Legalize scalable VF hints
In the following loop:

  void foo(int *a, int *b, int N) {
    for (int i=0; i<N; ++i)
      a[i + 4] = a[i] + b[i];
  }

The loop dependence constrains the VF to a maximum of (4, fixed), which
would mean using <4 x i32> as the vector type in vectorization.
Extending this to scalable vectorization, a VF of (4, scalable) implies
a vector type of <vscale x 4 x i32>. To determine if this is legal
vscale must be taken into account. For this example, unless
max(vscale)=1, it's unsafe to vectorize.

For SVE, the number of bits in an SVE register is architecturally
defined to be a multiple of 128 bits with a maximum of 2048 bits, thus
the maximum vscale is 16. In the loop above it is therefore unfeasible
to vectorize with SVE. However, in this loop:

  void foo(int *a, int *b, int N) {
    #pragma clang loop vectorize_width(X, scalable)
    for (int i=0; i<N; ++i)
      a[i + 32] = a[i] + b[i];
  }

As long as max(vscale) multiplied by the number of lanes 'X' doesn't
exceed the dependence distance, it is safe to vectorize. For SVE a VF of
(2, scalable) is within this constraint, since a vector of <16 x 2 x 32>
will have no dependencies between lanes. For any number of lanes larger
than this it would be unsafe to vectorize.

This patch extends 'computeFeasibleMaxVF' to legalize scalable VFs
specified as loop hints, implementing the following behaviour:
  * If the backend does not support scalable vectors, ignore the hint.
  * If scalable vectorization is unfeasible given the loop
    dependence, like in the first example above for SVE, then use a
    fixed VF.
  * Accept scalable VFs if it's safe to do so.
  * Otherwise, clamp scalable VFs that exceed the maximum safe VF.

Reviewed By: sdesmalen, fhahn, david-arm

Differential Revision: https://reviews.llvm.org/D91718
2021-01-08 10:49:44 +00:00
..
ADCE [SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 1 2021-01-01 03:25:22 +03:00
AddDiscriminators
AggressiveInstCombine [AggressiveInstCombine] Generalize foldGuardedRotateToFunnelShift to generic funnel shifts (REAPPLIED) 2020-12-21 15:22:27 +00:00
AlignmentFromAssumptions Reland [AssumeBundles] Use operand bundles to encode alignment assumptions 2020-09-12 15:36:06 +02:00
ArgumentPromotion [ArgPromotion] Delay dead GEP removal until doPromotion. 2021-01-04 09:51:20 +00:00
AtomicExpand [AArch64] Out-of-line atomics (-moutline-atomics) implementation. 2020-11-20 13:30:12 +00:00
Attributor [InstCombine] Generalize icmp handling in isKnownNonZero() 2020-12-25 16:49:23 +01:00
BDCE Precommit transform tests that have poison as insertelement's placeholder 2020-12-24 11:46:17 +09:00
BlockExtractor [BlockExtract][NewPM] Port -extract-blocks to NPM 2020-10-21 12:51:11 -07:00
BranchFolding
CallSiteSplitting [SimplifyCFG] Teach simplifyUnreachable() to preserve DomTree 2020-12-18 00:37:22 +03:00
CalledValuePropagation
CanonicalizeAliases [NPM] Move more O0 pass building into PassBuilder 2020-11-19 11:22:23 -08:00
CanonicalizeFreezeInLoops
CodeExtractor [HotColdSplit] Reflect full cost of parameters in split penalty 2020-12-18 17:06:17 -08:00
CodeGenPrepare Precommit tests that have poison as shufflevector's placeholder 2020-12-29 17:09:31 +09:00
ConstantHoisting [test] Fix const-addr-no-neg-offset.ll under NPM 2020-11-13 23:29:58 -08:00
ConstantMerge
ConstraintElimination [ConstraintElimination] Add support for select form of and/or 2020-12-30 21:27:36 +09:00
Coroutines [CoroSplit][NewPM] Don't call LazyCallGraph functions to split when no clones 2021-01-07 14:06:35 -08:00
CorrelatedValuePropagation [LVI] Handle unions of conditions 2021-01-01 16:46:21 +01:00
CrossDSOCFI
DCE [DCE] Always get TargetLibraryInfo 2020-11-17 20:41:05 -08:00
DeadArgElim OpaquePtr: Bulk update tests to use typed sret 2020-11-20 17:58:26 -05:00
DeadStoreElimination Precommit tests that have poison as shufflevector's placeholder 2020-12-29 17:09:31 +09:00
DivRemPairs
EarlyCSE [EarlyCSE] Use m_LogicalAnd/Or matchers to handle branch conditions 2020-12-28 05:36:26 +09:00
EliminateAvailableExternally
EntryExitInstrumenter
ExpandMemCmp
FixIrreducible [FixIrreducible][NewPM] Port -fix-irreducible to NPM 2020-10-09 09:22:09 -07:00
Float2Int
ForcedFunctionAttrs Force Remove Attribute 2020-08-19 17:30:13 -04:00
FunctionAttrs [FuncAttrs] Infer noreturn 2021-01-05 13:25:42 -08:00
FunctionImport [CGProfile] allows bitcast in metadata node storing function pointers 2020-11-13 09:28:21 -08:00
GCOVProfiling [gcov] Add spanning tree optimization 2020-09-13 00:07:31 -07:00
GVN [InstSimplify] Fold call null/undef to poison 2021-01-06 21:09:30 +01:00
GVNHoist [EarlyCSE] Verify hash code in regression tests 2020-09-04 10:40:35 -04:00
GVNSink [SimplifyCFG] Teach HoistThenElseCodeToIf() to preserve DomTree 2020-12-30 00:48:10 +03:00
GlobalDCE [SimplifyCFG] MergeBlockIntoPredecessor() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
GlobalMerge
GlobalOpt Fix for Bug 48055. 2020-12-04 11:05:01 -08:00
GlobalSplit
GuardWidening [NewPM][GuardWidening] Fix loop guard widening tests under NPM 2020-08-06 15:32:59 -07:00
HardwareLoops [FileCheck] Enforce --allow-unused-prefixes=false for llvm/test/Transforms 2020-12-09 08:51:38 -08:00
HelloNew Reland [docs][NewPM] Add docs for writing NPM passes 2020-09-14 16:06:19 -07:00
HotColdSplit [HotColdSplit] Reflect full cost of parameters in split penalty 2020-12-18 17:06:17 -08:00
IRCE [IRCE] Add test case for PR48051 2020-12-14 12:01:19 +00:00
IROutliner [IROutliner] Refactoring errors in the cost model from past patches. 2021-01-04 00:11:18 -06:00
IndVarSimplify Revert "[LoopDeletion] Break backedge of loops when known not taken" 2021-01-04 09:50:47 -08:00
IndirectBrExpand
InferAddressSpaces [NewPM] Port infer-address-spaces 2020-12-28 19:58:12 -08:00
InferFunctionAttrs Precommit transform tests that have poison as insertelement's placeholder 2020-12-24 11:46:17 +09:00
Inline Precommit tests that have poison as shufflevector's placeholder 2020-12-29 17:09:31 +09:00
InstCombine [InstSimplify] Fold insertelement vec, poison, idx into vec 2021-01-07 10:10:14 +09:00
InstMerge OpaquePtr: Bulk update tests to use typed sret 2020-11-20 17:58:26 -05:00
InstNamer Port -instnamer to NPM 2020-10-22 12:08:36 -07:00
InstSimplify [InstSimplify] Fold insertelement vec, poison, idx into vec 2021-01-07 10:10:14 +09:00
InterleavedAccess [InterleavedAccess] Return correct 'modified' status. 2021-01-04 15:49:47 +00:00
Internalize
JumpThreading [JumpThreading][NewPM] Skip when target has divergent CF 2021-01-04 16:08:08 -08:00
LCSSA [DebugInfo] Avoid re-ordering assignments in LCSSA 2020-12-17 16:17:32 +00:00
LICM [SimplifyCFG] MergeBlockIntoPredecessor() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
LoadStoreVectorizer Precommit transform tests that have poison as insertelement's placeholder 2020-12-24 11:46:17 +09:00
LoopDataPrefetch
LoopDeletion [LoopDeletion] Also consider loops with subloops for deletion. 2021-01-06 14:49:00 +00:00
LoopDistribute [LoopDistribute] Add tests with uncomputable BTCs. 2021-01-01 13:57:03 +00:00
LoopFlatten [test] Fix widen-iv.ll under NPM 2020-12-07 19:34:31 -08:00
LoopFusion [test] Fix LoopFusion tests under NewPM 2020-12-07 17:37:42 -08:00
LoopIdiom [LoopIdiom] 'left-shift until bittest': don't forget to check that PHI node is in loop header 2020-12-30 23:58:41 +03:00
LoopInstSimplify
LoopInterchange [SimplifyCFG] MergeBlockIntoPredecessor() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
LoopLoadElim [LoopLoadElim] Add tests with uncomputable BTCs. 2021-01-01 13:57:02 +00:00
LoopPredication
LoopReroll [SCEV] Strength nowrap flags after constant folding 2020-10-25 18:00:22 +01:00
LoopRotate [test] Rewrite phi-empty.ll into a unittest 2020-12-08 09:59:31 -08:00
LoopSimplify Precommit tests that have poison as shufflevector's placeholder 2020-12-29 17:09:31 +09:00
LoopSimplifyCFG [LoopSimplifyCFG][NewPM] Rename simplify-cfg -> loop-simplifycfg 2020-09-21 08:27:19 -07:00
LoopStrengthReduce [DebugInfo] Avoid LSR crash on large integer inputs 2021-01-05 10:25:37 +00:00
LoopTransformWarning
LoopUnroll [PGO][PGSO] Let unroll hints take precedence over PGSO. 2021-01-07 10:10:31 -08:00
LoopUnrollAndJam [NPM] Share pass building options with legacy PM 2020-11-23 13:04:05 -08:00
LoopUnswitch [test] Pin partial-unswitch.ll to legacy PM 2021-01-06 11:53:07 -08:00
LoopVectorize [LV] Legalize scalable VF hints 2021-01-08 10:49:44 +00:00
LoopVersioning Revert "[BasicAA] Handle two unknown sizes for GEPs" 2020-12-18 17:59:12 +00:00
LoopVersioningLICM [test] Fix Transforms/LoopVersioningLICM under NPM 2020-12-07 21:54:38 -08:00
LowerAtomic
LowerConstantIntrinsics
LowerExpectIntrinsic Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM" 2020-11-14 13:12:38 +03:00
LowerGuardIntrinsic
LowerInvoke
LowerMatrixIntrinsics Use unary CreateShuffleVector if possible 2020-12-30 22:36:08 +09:00
LowerSwitch [LowerSwitch][NewPM] Port lowerswitch to NPM 2020-09-15 18:18:31 -07:00
LowerTypeTests [FileCheck] Enforce --allow-unused-prefixes=false for llvm/test/Transforms 2020-12-09 08:51:38 -08:00
LowerWidenableCondition
MakeGuardsExplicit
Mem2Reg
MemCpyOpt [FileCheck] Enforce --allow-unused-prefixes=false for llvm/test/Transforms 2020-12-09 08:51:38 -08:00
MergeFunc OpaquePtr: Bulk update tests to use typed sret 2020-11-20 17:58:26 -05:00
MergeICmps [MergeICmps] Fix missing split. 2020-12-01 16:50:55 +01:00
MetaRenamer OpaquePtr: Bulk update tests to use typed sret 2020-11-20 17:58:26 -05:00
NameAnonGlobals [NPM] Move more O0 pass building into PassBuilder 2020-11-19 11:22:23 -08:00
NaryReassociate [NARY-REASSOCIATE] Simplify traversal logic by post deleting dead instructions 2020-12-04 16:17:50 +07:00
NewGVN Precommit transform tests that have poison as insertelement's placeholder 2020-12-24 11:46:17 +09:00
ObjCARC [ObjC][ARC] Fix a bug where the inline-asm retain/claim RV marker wasn't 2020-12-18 16:59:06 -08:00
OpenMP [OpenMP] Use assumptions during ICV tracking 2020-12-15 16:51:34 -06:00
PGOProfile [SimplifyCFG] Teach FoldValueComparisonIntoPredecessors() to preserve DomTree, part 2 2021-01-01 03:25:24 +03:00
PartialInlining [PartialInliner]: Handle code regions in a switch stmt cases 2020-11-02 14:32:45 -05:00
PartiallyInlineLibCalls
PhaseOrdering [Constant] Update ConstantVector::get to return poison if all input elems are poison 2021-01-07 09:26:07 +09:00
PlaceSafepoints [PlaceSafepoints] Pin tests to legacy PM 2020-10-26 20:07:37 -07:00
PreISelIntrinsicLowering
PruneEH [FuncAttrs] Infer noreturn 2021-01-05 13:25:42 -08:00
Reassociate [Reassociate] Don't convert add-like-or's into add's if they appear to be part of load-combining idiom 2020-11-18 17:55:02 +03:00
Reg2Mem [Reg2Mem] add support for the new pass manager 2020-11-08 11:14:05 +00:00
RewriteStatepointsForGC [IR] Let IRBuilder's CreateVectorSplat/CreateShuffleVector use poison as placeholder 2020-12-30 04:21:04 +09:00
SCCP [SimplifyCFG] TryToSimplifyUncondBranchFromEmptyBlock() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
SLPVectorizer [SLP]Need shrink the load vector after reordering. 2021-01-07 04:50:48 -08:00
SROA Use unary CreateShuffleVector if possible 2020-12-30 22:36:08 +09:00
SafeStack OpaquePtr: Bulk update tests to use typed byval 2020-11-20 14:00:46 -05:00
SampleProfile [CSSPGO] Consume pseudo-probe-based AutoFDO profile 2020-12-16 15:57:18 -08:00
ScalarizeMaskedMemIntrin [ScalarizeMaskedMemIntrin][X86] Refresh missed transform test cases from rGc0c3b9a25fee 2020-08-10 11:14:01 +01:00
Scalarizer [Scalarizer] Use poison as insertelement's placeholder 2021-01-04 00:35:28 +09:00
SeparateConstOffsetFromGEP [NewPM] Port -separate-const-offset-from-gep 2020-11-09 17:42:36 -08:00
SimpleLoopUnswitch OpaquePtr: Bulk update tests to use typed sret 2020-11-20 17:58:26 -05:00
SimplifyCFG [NFC][SimplifyCFG] Add a test with an undef cond branch to identical destinations 2021-01-08 02:15:26 +03:00
Sink Sink: Handle instruction sink when a user is dead 2020-10-09 16:20:26 -07:00
SpeculateAroundPHIs
SpeculativeExecution Precommit tests that have poison as shufflevector's placeholder 2020-12-29 17:09:31 +09:00
StraightLineStrengthReduce [NPM] Add remaining test of -slsr 2020-11-17 14:41:01 +08:00
StripDeadPrototypes
StripSymbols [NewPM] Port strip* passes to NPM 2020-09-15 18:25:12 -07:00
StructurizeCFG [test] Pin backedge-id-bug-xfail.ll to legacy PM 2021-01-04 13:09:42 -08:00
SyntheticCountsPropagation
TailCallElim OpaquePtr: Bulk update tests to use typed sret 2020-11-20 17:58:26 -05:00
ThinLTOBitcodeWriter [test] Fix split-vfunc.ll under NPM 2020-11-19 14:59:05 -08:00
TypePromotion/ARM
UnifyFunctionExitNodes [NPM] Port -mergereturn to NPM 2020-10-20 10:33:58 -07:00
UnifyLoopExits [NPM] port -unify-loop-exits to NPM 2020-10-20 10:46:57 -07:00
UniqueInternalLinkageNames [NewPM] Add unique-internal-linkage-names to PassRegistry.def 2020-11-09 12:54:13 -08:00
UniqueLinkageNames Moving UniqueInternalLinkageNamesPass to the start of IR pipelines. 2021-01-02 14:26:21 -08:00
Util Add pass to add !annotate metadata from @llvm.global.annotations. 2020-11-16 14:57:11 +00:00
VectorCombine [Constant] Update ConstantVector::get to return poison if all input elems are poison 2021-01-07 09:26:07 +09:00
WholeProgramDevirt [WholeProgramDevirt][NewPM] Add NPM testing path to match legacy pass 2020-09-30 17:27:37 -07:00
lit.local.cfg [FileCheck] Enforce --allow-unused-prefixes=false for llvm/test/Transforms 2020-12-09 08:51:38 -08:00