VectorUtils.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #ifndef LLVM_TRANSFORMS_UTILS_VECTORUTILS_H
  14. #define LLVM_TRANSFORMS_UTILS_VECTORUTILS_H
  15. #include "llvm/Analysis/TargetLibraryInfo.h"
  16. #include "llvm/IR/IntrinsicInst.h"
  17. #include "llvm/IR/Intrinsics.h"
  18. namespace llvm {
  19. class GetElementPtrInst;
  20. class Loop;
  21. class ScalarEvolution;
  22. class Type;
  23. class Value;
  24. /// \brief Identify if the intrinsic is trivially vectorizable.
  25. /// This method returns true if the intrinsic's argument types are all
  26. /// scalars for the scalar form of the intrinsic and all vectors for
  27. /// the vector form of the intrinsic.
  28. bool isTriviallyVectorizable(Intrinsic::ID ID);
  29. /// \brief Identifies if the intrinsic has a scalar operand. It checks for
  30. /// ctlz,cttz and powi special intrinsics whose argument is scalar.
  31. bool hasVectorInstrinsicScalarOpd(Intrinsic::ID ID, unsigned ScalarOpdIdx);
  32. /// \brief Identify if call has a unary float signature
  33. /// It returns input intrinsic ID if call has a single argument,
  34. /// argument type and call instruction type should be floating
  35. /// point type and call should only reads memory.
  36. /// else return not_intrinsic.
  37. Intrinsic::ID checkUnaryFloatSignature(const CallInst &I,
  38. Intrinsic::ID ValidIntrinsicID);
  39. /// \brief Identify if call has a binary float signature
  40. /// It returns input intrinsic ID if call has two arguments,
  41. /// arguments 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 checkBinaryFloatSignature(const CallInst &I,
  45. Intrinsic::ID ValidIntrinsicID);
  46. /// \brief Returns intrinsic ID for call.
  47. /// For the input call instruction it finds mapping intrinsic and returns
  48. /// its intrinsic ID, in case it does not found it return not_intrinsic.
  49. Intrinsic::ID getIntrinsicIDForCall(CallInst *CI, const TargetLibraryInfo *TLI);
  50. /// \brief Find the operand of the GEP that should be checked for consecutive
  51. /// stores. This ignores trailing indices that have no effect on the final
  52. /// pointer.
  53. unsigned getGEPInductionOperand(const GetElementPtrInst *Gep);
  54. /// \brief If the argument is a GEP, then returns the operand identified by
  55. /// getGEPInductionOperand. However, if there is some other non-loop-invariant
  56. /// operand, it returns that instead.
  57. Value *stripGetElementPtr(Value *Ptr, ScalarEvolution *SE, Loop *Lp);
  58. /// \brief If a value has only one user that is a CastInst, return it.
  59. Value *getUniqueCastUse(Value *Ptr, Loop *Lp, Type *Ty);
  60. /// \brief Get the stride of a pointer access in a loop. Looks for symbolic
  61. /// strides "a[i*stride]". Returns the symbolic stride, or null otherwise.
  62. Value *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp);
  63. /// \brief Given a vector and an element number, see if the scalar value is
  64. /// already around as a register, for example if it were inserted then extracted
  65. /// from the vector.
  66. Value *findScalarElement(Value *V, unsigned EltNo);
  67. } // llvm namespace
  68. #endif