LLVM  16.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 class TargetLibraryInfo;
27 
29  /// Replaces the VPInstructions in \p Plan with corresponding
30  /// widen recipes.
31  static void
32  VPInstructionsToVPRecipes(Loop *OrigLoop, VPlanPtr &Plan,
34  GetIntOrFpInductionDescriptor,
35  SmallPtrSetImpl<Instruction *> &DeadInstructions,
36  ScalarEvolution &SE, const TargetLibraryInfo &TLI);
37 
38  static bool sinkScalarOperands(VPlan &Plan);
39 
40  static bool mergeReplicateRegions(VPlan &Plan);
41 
42  /// Remove redundant casts of inductions.
43  ///
44  /// Such redundant casts are casts of induction variables that can be ignored,
45  /// because we already proved that the casted phi is equal to the uncasted phi
46  /// in the vectorized loop. There is no need to vectorize the cast - the same
47  /// value can be used for both the phi and casts in the vector loop.
48  static void removeRedundantInductionCasts(VPlan &Plan);
49 
50  /// Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV
51  /// recipe, if it exists.
52  static void removeRedundantCanonicalIVs(VPlan &Plan);
53 
54  static void removeDeadRecipes(VPlan &Plan);
55 
56  /// If any user of a VPWidenIntOrFpInductionRecipe needs scalar values,
57  /// provide them by building scalar steps off of the canonical scalar IV and
58  /// update the original IV's users. This is an optional optimization to reduce
59  /// the needs of vector extracts.
60  static void optimizeInductions(VPlan &Plan, ScalarEvolution &SE);
61 
62  /// Remove redundant EpxandSCEVRecipes in \p Plan's entry block by replacing
63  /// them with already existing recipes expanding the same SCEV expression.
64  static void removeRedundantExpandSCEVRecipes(VPlan &Plan);
65 };
66 
67 } // namespace llvm
68 
69 #endif // LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:547
llvm::VPlanTransforms::removeDeadRecipes
static void removeDeadRecipes(VPlan &Plan)
Definition: VPlanTransforms.cpp:363
llvm::ScalarEvolution
The main scalar evolution driver.
Definition: ScalarEvolution.h:449
llvm::VPlanPtr
std::unique_ptr< VPlan > VPlanPtr
Definition: VPlan.h:103
llvm::VPlanTransforms::removeRedundantCanonicalIVs
static void removeRedundantCanonicalIVs(VPlan &Plan)
Try to replace VPWidenCanonicalIVRecipes with a widened canonical IV recipe, if it exists.
Definition: VPlanTransforms.cpp:330
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:380
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:108
llvm::VPlanTransforms::VPInstructionsToVPRecipes
static void VPInstructionsToVPRecipes(Loop *OrigLoop, VPlanPtr &Plan, function_ref< const InductionDescriptor *(PHINode *)> GetIntOrFpInductionDescriptor, SmallPtrSetImpl< Instruction * > &DeadInstructions, ScalarEvolution &SE, const TargetLibraryInfo &TLI)
Replaces the VPInstructions in Plan with corresponding widen recipes.
Definition: VPlanTransforms.cpp:23
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:416
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition: TargetLibraryInfo.h:225
llvm::VPlanTransforms::removeRedundantInductionCasts
static void removeRedundantInductionCasts(VPlan &Plan)
Remove redundant casts of inductions.
Definition: VPlanTransforms.cpp:298
llvm::VPlanTransforms
Definition: VPlanTransforms.h:28
llvm::PHINode
Definition: Instructions.h:2698
llvm::SmallPtrSetImpl< Instruction * >
llvm::VPlanTransforms::mergeReplicateRegions
static bool mergeReplicateRegions(VPlan &Plan)
Definition: VPlanTransforms.cpp:214
llvm::VPlan
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
Definition: VPlan.h:2492