LLVM  15.0.0git
VPlanTransforms.h
Go to the documentation of this file.
1 //===- VPlanTransforms.h - Utility VPlan to VPlan transforms --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file provides utility VPlan to VPlan transformations.
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
14 #define LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
15 
16 #include "VPlan.h"
18 
19 namespace llvm {
20 
21 class InductionDescriptor;
22 class Instruction;
23 class PHINode;
24 class ScalarEvolution;
25 class Loop;
26 
28  /// Replaces the VPInstructions in \p Plan with corresponding
29  /// widen recipes.
30  static void
31  VPInstructionsToVPRecipes(Loop *OrigLoop, VPlanPtr &Plan,
33  GetIntOrFpInductionDescriptor,
34  SmallPtrSetImpl<Instruction *> &DeadInstructions,
35  ScalarEvolution &SE);
36 
37  static bool sinkScalarOperands(VPlan &Plan);
38 
39  static bool mergeReplicateRegions(VPlan &Plan);
40 
41  /// Remove redundant casts of inductions.
42  ///
43  /// Such redundant casts are casts of induction variables that can be ignored,
44  /// because we already proved that the casted phi is equal to the uncasted phi
45  /// in the vectorized loop. There is no need to vectorize the cast - the same
46  /// value can be used for both the phi and casts in the vector loop.
47  static void removeRedundantInductionCasts(VPlan &Plan);
48 
49  /// Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV
50  /// recipe, if it exists.
51  static void removeRedundantCanonicalIVs(VPlan &Plan);
52 
53  /// Try to remove dead recipes. At the moment, only dead header recipes are
54  /// removed.
55  static void removeDeadRecipes(VPlan &Plan, Loop &OrigLoop);
56 
57  /// If any user of a VPWidenIntOrFpInductionRecipe needs scalar values,
58  /// provide them by building scalar steps off of the canonical scalar IV and
59  /// update the original IV's users. This is an optional optimization to reduce
60  /// the needs of vector extracts.
61  static void optimizeInductions(VPlan &Plan, ScalarEvolution &SE);
62 
63  /// Remove redundant EpxandSCEVRecipes in \p Plan's entry block by replacing
64  /// them with already existing recipes expanding the same SCEV expression.
65  static void removeRedundantExpandSCEVRecipes(VPlan &Plan);
66 };
67 
68 } // namespace llvm
69 
70 #endif // LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::VPlanTransforms::VPInstructionsToVPRecipes
static void VPInstructionsToVPRecipes(Loop *OrigLoop, VPlanPtr &Plan, function_ref< const InductionDescriptor *(PHINode *)> GetIntOrFpInductionDescriptor, SmallPtrSetImpl< Instruction * > &DeadInstructions, ScalarEvolution &SE)
Replaces the VPInstructions in Plan with corresponding widen recipes.
Definition: VPlanTransforms.cpp:21
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:530
llvm::ScalarEvolution
The main scalar evolution driver.
Definition: ScalarEvolution.h:449
llvm::VPlanPtr
std::unique_ptr< VPlan > VPlanPtr
Definition: VPlan.h:97
llvm::VPlanTransforms::removeRedundantCanonicalIVs
static void removeRedundantCanonicalIVs(VPlan &Plan)
Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV recipe, if it exists.
Definition: VPlanTransforms.cpp:333
llvm::InductionDescriptor
A struct for saving information about induction variables.
Definition: IVDescriptors.h:306
llvm::VPlanTransforms::optimizeInductions
static void optimizeInductions(VPlan &Plan, ScalarEvolution &SE)
If any user of a VPWidenIntOrFpInductionRecipe needs scalar values, provide them by building scalar s...
Definition: VPlanTransforms.cpp:415
STLFunctionalExtras.h
VPlan.h
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::VPlanTransforms::sinkScalarOperands
static bool sinkScalarOperands(VPlan &Plan)
Definition: VPlanTransforms.cpp:106
llvm::VPlanTransforms::removeRedundantExpandSCEVRecipes
static void removeRedundantExpandSCEVRecipes(VPlan &Plan)
Remove redundant EpxandSCEVRecipes in Plan's entry block by replacing them with already existing reci...
Definition: VPlanTransforms.cpp:454
llvm::VPlanTransforms::removeDeadRecipes
static void removeDeadRecipes(VPlan &Plan, Loop &OrigLoop)
Try to remove dead recipes.
Definition: VPlanTransforms.cpp:387
llvm::VPlanTransforms::removeRedundantInductionCasts
static void removeRedundantInductionCasts(VPlan &Plan)
Remove redundant casts of inductions.
Definition: VPlanTransforms.cpp:301
llvm::VPlanTransforms
Definition: VPlanTransforms.h:27
llvm::PHINode
Definition: Instructions.h:2664
llvm::SmallPtrSetImpl< Instruction * >
llvm::VPlanTransforms::mergeReplicateRegions
static bool mergeReplicateRegions(VPlan &Plan)
Definition: VPlanTransforms.cpp:217
llvm::VPlan
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:2442