SLPVectorizer: Only vectorize intrinsics whose operands are widened equally
[oota-llvm.git] / include / llvm / Transforms / Utils / 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 namespace llvm {
18
19 /// \brief Identify if the intrinsic is trivially vectorizable.
20 ///
21 /// This method returns true if the intrinsic's argument types are all
22 /// scalars for the scalar form of the intrinsic and all vectors for
23 /// the vector form of the intrinsic.
24 static inline bool isTriviallyVectorizable(Intrinsic::ID ID) {
25   switch (ID) {
26   case Intrinsic::sqrt:
27   case Intrinsic::sin:
28   case Intrinsic::cos:
29   case Intrinsic::exp:
30   case Intrinsic::exp2:
31   case Intrinsic::log:
32   case Intrinsic::log10:
33   case Intrinsic::log2:
34   case Intrinsic::fabs:
35   case Intrinsic::copysign:
36   case Intrinsic::floor:
37   case Intrinsic::ceil:
38   case Intrinsic::trunc:
39   case Intrinsic::rint:
40   case Intrinsic::nearbyint:
41   case Intrinsic::round:
42   case Intrinsic::ctpop:
43   case Intrinsic::pow:
44   case Intrinsic::fma:
45   case Intrinsic::fmuladd:
46     return true;
47   default:
48     return false;
49   }
50 }
51
52 } // llvm namespace
53
54 #endif