Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / lib / Transforms / Vectorize / VPlanAnalysis.h
blob34b6b74588325bc3e7ff3bda061dffdf8ff8049e
1 //===- VPlanAnalysis.h - Various Analyses working on VPlan ------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
10 #define LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
12 #include "llvm/ADT/DenseMap.h"
14 namespace llvm {
16 class LLVMContext;
17 class VPValue;
18 class VPBlendRecipe;
19 class VPInterleaveRecipe;
20 class VPInstruction;
21 class VPReductionPHIRecipe;
22 class VPWidenRecipe;
23 class VPWidenCallRecipe;
24 class VPWidenCastRecipe;
25 class VPWidenIntOrFpInductionRecipe;
26 class VPWidenMemoryInstructionRecipe;
27 struct VPWidenSelectRecipe;
28 class VPReplicateRecipe;
29 class Type;
31 /// An analysis for type-inference for VPValues.
32 /// It infers the scalar type for a given VPValue by bottom-up traversing
33 /// through defining recipes until root nodes with known types are reached (e.g.
34 /// live-ins or load recipes). The types are then propagated top down through
35 /// operations.
36 /// Note that the analysis caches the inferred types. A new analysis object must
37 /// be constructed once a VPlan has been modified in a way that invalidates any
38 /// of the previously inferred types.
39 class VPTypeAnalysis {
40 DenseMap<const VPValue *, Type *> CachedTypes;
41 LLVMContext &Ctx;
43 Type *inferScalarTypeForRecipe(const VPBlendRecipe *R);
44 Type *inferScalarTypeForRecipe(const VPInstruction *R);
45 Type *inferScalarTypeForRecipe(const VPWidenCallRecipe *R);
46 Type *inferScalarTypeForRecipe(const VPWidenRecipe *R);
47 Type *inferScalarTypeForRecipe(const VPWidenIntOrFpInductionRecipe *R);
48 Type *inferScalarTypeForRecipe(const VPWidenMemoryInstructionRecipe *R);
49 Type *inferScalarTypeForRecipe(const VPWidenSelectRecipe *R);
50 Type *inferScalarTypeForRecipe(const VPReplicateRecipe *R);
52 public:
53 VPTypeAnalysis(LLVMContext &Ctx) : Ctx(Ctx) {}
55 /// Infer the type of \p V. Returns the scalar type of \p V.
56 Type *inferScalarType(const VPValue *V);
59 } // end namespace llvm
61 #endif // LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H