Whitespace.
[oota-llvm.git] / include / llvm / Analysis / VectorUtils.h
1 //===- llvm/Transforms/Utils/VectorUtils.h - Vector utilities -*- C++ -*-=====//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines some vectorizer utilities.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TRANSFORMS_UTILS_VECTORUTILS_H
15 #define LLVM_TRANSFORMS_UTILS_VECTORUTILS_H
16
17 #include "llvm/Analysis/TargetLibraryInfo.h"
18 #include "llvm/IR/IntrinsicInst.h"
19 #include "llvm/IR/Intrinsics.h"
20
21 namespace llvm {
22
23 class GetElementPtrInst;
24 class Loop;
25 class ScalarEvolution;
26 class Type;
27 class Value;
28
29 /// \brief Identify if the intrinsic is trivially vectorizable.
30 /// This method returns true if the intrinsic's argument types are all
31 /// scalars for the scalar form of the intrinsic and all vectors for
32 /// the vector form of the intrinsic.
33 bool isTriviallyVectorizable(Intrinsic::ID ID);
34
35 /// \brief Identifies if the intrinsic has a scalar operand. It checks for
36 /// ctlz,cttz and powi special intrinsics whose argument is scalar.
37 bool hasVectorInstrinsicScalarOpd(Intrinsic::ID ID, unsigned ScalarOpdIdx);
38
39 /// \brief Identify if call has a unary float signature
40 /// It returns input intrinsic ID if call has a single argument,
41 /// argument type and call instruction type should be floating
42 /// point type and call should only reads memory.
43 /// else return not_intrinsic.
44 Intrinsic::ID checkUnaryFloatSignature(const CallInst &I,
45                                        Intrinsic::ID ValidIntrinsicID);
46
47 /// \brief Identify if call has a binary float signature
48 /// It returns input intrinsic ID if call has two arguments,
49 /// arguments type and call instruction type should be floating
50 /// point type and call should only reads memory.
51 /// else return not_intrinsic.
52 Intrinsic::ID checkBinaryFloatSignature(const CallInst &I,
53                                         Intrinsic::ID ValidIntrinsicID);
54
55 /// \brief Returns intrinsic ID for call.
56 /// For the input call instruction it finds mapping intrinsic and returns
57 /// its intrinsic ID, in case it does not found it return not_intrinsic.
58 Intrinsic::ID getIntrinsicIDForCall(CallInst *CI, const TargetLibraryInfo *TLI);
59
60 /// \brief Find the operand of the GEP that should be checked for consecutive
61 /// stores. This ignores trailing indices that have no effect on the final
62 /// pointer.
63 unsigned getGEPInductionOperand(const GetElementPtrInst *Gep);
64
65 /// \brief If the argument is a GEP, then returns the operand identified by
66 /// getGEPInductionOperand. However, if there is some other non-loop-invariant
67 /// operand, it returns that instead.
68 Value *stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp);
69
70 /// \brief If a value has only one user that is a CastInst, return it.
71 Value *getUniqueCastUse(Value *Ptr, Loop *Lp, Type *Ty);
72
73 /// \brief Get the stride of a pointer access in a loop. Looks for symbolic
74 /// strides "a[i*stride]". Returns the symbolic stride, or null otherwise.
75 Value *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp);
76
77 /// \brief Given a vector and an element number, see if the scalar value is
78 /// already around as a register, for example if it were inserted then extracted
79 /// from the vector.
80 Value *findScalarElement(Value *V, unsigned EltNo);
81
82 /// \brief Get splat value if the input is a splat vector or return nullptr.
83 /// The value may be extracted from a splat constants vector or from
84 /// a sequence of instructions that broadcast a single value into a vector.
85 Value *getSplatValue(Value *V);
86
87 } // llvm namespace
88
89 #endif