xref: /freebsd-src/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanTransforms.h (revision c9ccf3a32da427475985b85d7df023ccfb138c27)
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"
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/Transforms/Vectorize/LoopVectorizationLegality.h"
19 
20 namespace llvm {
21 
22 class InductionDescriptor;
23 class Instruction;
24 class PHINode;
25 class ScalarEvolution;
26 
27 struct VPlanTransforms {
28   /// Replaces the VPInstructions in \p Plan with corresponding
29   /// widen recipes.
30   static void
31   VPInstructionsToVPRecipes(Loop *OrigLoop, VPlanPtr &Plan,
32                             function_ref<const InductionDescriptor *(PHINode *)>
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 
54 } // namespace llvm
55 
56 #endif // LLVM_TRANSFORMS_VECTORIZE_VPLANTRANSFORMS_H
57