[llvm] 01b8744 - [NFC][Analysis] Change struct VecDesc to use ElementCount

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 03:08:18 PST 2021


Author: David Sherwood
Date: 2021-02-12T11:07:58Z
New Revision: 01b87444cb02c38147dccc7049b32675de860d47

URL: https://github.com/llvm/llvm-project/commit/01b87444cb02c38147dccc7049b32675de860d47
DIFF: https://github.com/llvm/llvm-project/commit/01b87444cb02c38147dccc7049b32675de860d47.diff

LOG: [NFC][Analysis] Change struct VecDesc to use ElementCount

This patch changes the VecDesc struct to use ElementCount
instead of an unsigned VF value, in preparation for
future work that adds support for vectorized versions of
math functions using scalable vectors. Since all I'm doing
in this patch is switching the type I believe it's a
non-functional change. I changed getWidestVF to now return
both the widest fixed-width and scalable VF values, but
currently the widest scalable value will be zero.

Differential Revision: https://reviews.llvm.org/D96011

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/TargetLibraryInfo.h
    llvm/include/llvm/Analysis/VecFuncs.def
    llvm/include/llvm/Support/TypeSize.h
    llvm/lib/Analysis/TargetLibraryInfo.cpp
    llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
    llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index b4a1d2b4c218..e913b918c4aa 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -28,7 +28,7 @@ class Triple;
 struct VecDesc {
   StringRef ScalarFnName;
   StringRef VectorFnName;
-  unsigned VectorizationFactor;
+  ElementCount VectorizationFactor;
 };
 
   enum LibFunc : unsigned {
@@ -152,7 +152,7 @@ class TargetLibraryInfoImpl {
 
   /// Return true if the function F has a vector equivalent with vectorization
   /// factor VF.
-  bool isFunctionVectorizable(StringRef F, unsigned VF) const {
+  bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const {
     return !getVectorizedFunction(F, VF).empty();
   }
 
@@ -162,7 +162,7 @@ class TargetLibraryInfoImpl {
 
   /// Return the name of the equivalent of F, vectorized with factor VF. If no
   /// such mapping exists, return the empty string.
-  StringRef getVectorizedFunction(StringRef F, unsigned VF) const;
+  StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const;
 
   /// Set to true iff i32 parameters to library functions should have signext
   /// or zeroext attributes if they correspond to C-level int or unsigned int,
@@ -190,7 +190,8 @@ class TargetLibraryInfoImpl {
 
   /// Returns the largest vectorization factor used in the list of
   /// vector functions.
-  unsigned getWidestVF(StringRef ScalarF) const;
+  void getWidestVF(StringRef ScalarF, ElementCount &FixedVF,
+                   ElementCount &Scalable) const;
 };
 
 /// Provides information about what library functions are available for
@@ -305,13 +306,13 @@ class TargetLibraryInfo {
   bool has(LibFunc F) const {
     return getState(F) != TargetLibraryInfoImpl::Unavailable;
   }
-  bool isFunctionVectorizable(StringRef F, unsigned VF) const {
+  bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const {
     return Impl->isFunctionVectorizable(F, VF);
   }
   bool isFunctionVectorizable(StringRef F) const {
     return Impl->isFunctionVectorizable(F);
   }
-  StringRef getVectorizedFunction(StringRef F, unsigned VF) const {
+  StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const {
     return Impl->getVectorizedFunction(F, VF);
   }
 
@@ -397,8 +398,9 @@ class TargetLibraryInfo {
   }
   /// Returns the largest vectorization factor used in the list of
   /// vector functions.
-  unsigned getWidestVF(StringRef ScalarF) const {
-    return Impl->getWidestVF(ScalarF);
+  void getWidestVF(StringRef ScalarF, ElementCount &FixedVF,
+                   ElementCount &ScalableVF) const {
+    Impl->getWidestVF(ScalarF, FixedVF, ScalableVF);
   }
 
   /// Check if the function "F" is listed in a library known to LLVM.

diff  --git a/llvm/include/llvm/Analysis/VecFuncs.def b/llvm/include/llvm/Analysis/VecFuncs.def
index cfc3d6115866..6f9636a79c11 100644
--- a/llvm/include/llvm/Analysis/VecFuncs.def
+++ b/llvm/include/llvm/Analysis/VecFuncs.def
@@ -17,6 +17,9 @@
 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF) VEC,
 #endif
 
+#define FIXED(NL) ElementCount::getFixed(NL)
+#define SCALABLE(NL) ElementCount::getScalable(NL)
+
 #if !(defined(TLI_DEFINE_VECFUNC))
 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF) {SCAL, VEC, VF},
 #endif 
@@ -25,394 +28,394 @@
 // Accelerate framework's Vector Functions
 
 // Floating-Point Arithmetic and Auxiliary Functions
-TLI_DEFINE_VECFUNC("ceilf", "vceilf", 4)
-TLI_DEFINE_VECFUNC("fabsf", "vfabsf", 4)
-TLI_DEFINE_VECFUNC("llvm.fabs.f32", "vfabsf", 4)
-TLI_DEFINE_VECFUNC("floorf", "vfloorf", 4)
-TLI_DEFINE_VECFUNC("sqrtf", "vsqrtf", 4)
-TLI_DEFINE_VECFUNC("llvm.sqrt.f32", "vsqrtf", 4)
+TLI_DEFINE_VECFUNC("ceilf", "vceilf", FIXED(4))
+TLI_DEFINE_VECFUNC("fabsf", "vfabsf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.fabs.f32", "vfabsf", FIXED(4))
+TLI_DEFINE_VECFUNC("floorf", "vfloorf", FIXED(4))
+TLI_DEFINE_VECFUNC("sqrtf", "vsqrtf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.sqrt.f32", "vsqrtf", FIXED(4))
 
 // Exponential and Logarithmic Functions
-TLI_DEFINE_VECFUNC("expf", "vexpf", 4)
-TLI_DEFINE_VECFUNC("llvm.exp.f32", "vexpf", 4)
-TLI_DEFINE_VECFUNC("expm1f", "vexpm1f", 4)
-TLI_DEFINE_VECFUNC("logf", "vlogf", 4)
-TLI_DEFINE_VECFUNC("llvm.log.f32", "vlogf", 4)
-TLI_DEFINE_VECFUNC("log1pf", "vlog1pf", 4)
-TLI_DEFINE_VECFUNC("log10f", "vlog10f", 4)
-TLI_DEFINE_VECFUNC("llvm.log10.f32", "vlog10f", 4)
-TLI_DEFINE_VECFUNC("logbf", "vlogbf", 4)
+TLI_DEFINE_VECFUNC("expf", "vexpf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp.f32", "vexpf", FIXED(4))
+TLI_DEFINE_VECFUNC("expm1f", "vexpm1f", FIXED(4))
+TLI_DEFINE_VECFUNC("logf", "vlogf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log.f32", "vlogf", FIXED(4))
+TLI_DEFINE_VECFUNC("log1pf", "vlog1pf", FIXED(4))
+TLI_DEFINE_VECFUNC("log10f", "vlog10f", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log10.f32", "vlog10f", FIXED(4))
+TLI_DEFINE_VECFUNC("logbf", "vlogbf", FIXED(4))
 
 // Trigonometric Functions
-TLI_DEFINE_VECFUNC("sinf", "vsinf", 4)
-TLI_DEFINE_VECFUNC("llvm.sin.f32", "vsinf", 4)
-TLI_DEFINE_VECFUNC("cosf", "vcosf", 4)
-TLI_DEFINE_VECFUNC("llvm.cos.f32", "vcosf", 4)
-TLI_DEFINE_VECFUNC("tanf", "vtanf", 4)
-TLI_DEFINE_VECFUNC("asinf", "vasinf", 4)
-TLI_DEFINE_VECFUNC("acosf", "vacosf", 4)
-TLI_DEFINE_VECFUNC("atanf", "vatanf", 4)
+TLI_DEFINE_VECFUNC("sinf", "vsinf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.sin.f32", "vsinf", FIXED(4))
+TLI_DEFINE_VECFUNC("cosf", "vcosf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.cos.f32", "vcosf", FIXED(4))
+TLI_DEFINE_VECFUNC("tanf", "vtanf", FIXED(4))
+TLI_DEFINE_VECFUNC("asinf", "vasinf", FIXED(4))
+TLI_DEFINE_VECFUNC("acosf", "vacosf", FIXED(4))
+TLI_DEFINE_VECFUNC("atanf", "vatanf", FIXED(4))
 
 // Hyperbolic Functions
-TLI_DEFINE_VECFUNC("sinhf", "vsinhf", 4)
-TLI_DEFINE_VECFUNC("coshf", "vcoshf", 4)
-TLI_DEFINE_VECFUNC("tanhf", "vtanhf", 4)
-TLI_DEFINE_VECFUNC("asinhf", "vasinhf", 4)
-TLI_DEFINE_VECFUNC("acoshf", "vacoshf", 4)
-TLI_DEFINE_VECFUNC("atanhf", "vatanhf", 4)
+TLI_DEFINE_VECFUNC("sinhf", "vsinhf", FIXED(4))
+TLI_DEFINE_VECFUNC("coshf", "vcoshf", FIXED(4))
+TLI_DEFINE_VECFUNC("tanhf", "vtanhf", FIXED(4))
+TLI_DEFINE_VECFUNC("asinhf", "vasinhf", FIXED(4))
+TLI_DEFINE_VECFUNC("acoshf", "vacoshf", FIXED(4))
+TLI_DEFINE_VECFUNC("atanhf", "vatanhf", FIXED(4))
 
 
 #elif defined(TLI_DEFINE_LIBMVEC_X86_VECFUNCS)
 // GLIBC Vector math Functions
 
-TLI_DEFINE_VECFUNC("sin", "_ZGVbN2v_sin", 2)
-TLI_DEFINE_VECFUNC("sin", "_ZGVdN4v_sin", 4)
+TLI_DEFINE_VECFUNC("sin", "_ZGVbN2v_sin", FIXED(2))
+TLI_DEFINE_VECFUNC("sin", "_ZGVdN4v_sin", FIXED(4))
 
-TLI_DEFINE_VECFUNC("sinf", "_ZGVbN4v_sinf", 4)
-TLI_DEFINE_VECFUNC("sinf", "_ZGVdN8v_sinf", 8)
+TLI_DEFINE_VECFUNC("sinf", "_ZGVbN4v_sinf", FIXED(4))
+TLI_DEFINE_VECFUNC("sinf", "_ZGVdN8v_sinf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.sin.f64", "_ZGVbN2v_sin", 2)
-TLI_DEFINE_VECFUNC("llvm.sin.f64", "_ZGVdN4v_sin", 4)
+TLI_DEFINE_VECFUNC("llvm.sin.f64", "_ZGVbN2v_sin", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.sin.f64", "_ZGVdN4v_sin", FIXED(4))
 
-TLI_DEFINE_VECFUNC("llvm.sin.f32", "_ZGVbN4v_sinf", 4)
-TLI_DEFINE_VECFUNC("llvm.sin.f32", "_ZGVdN8v_sinf", 8)
+TLI_DEFINE_VECFUNC("llvm.sin.f32", "_ZGVbN4v_sinf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.sin.f32", "_ZGVdN8v_sinf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("cos", "_ZGVbN2v_cos", 2)
-TLI_DEFINE_VECFUNC("cos", "_ZGVdN4v_cos", 4)
+TLI_DEFINE_VECFUNC("cos", "_ZGVbN2v_cos", FIXED(2))
+TLI_DEFINE_VECFUNC("cos", "_ZGVdN4v_cos", FIXED(4))
 
-TLI_DEFINE_VECFUNC("cosf", "_ZGVbN4v_cosf", 4)
-TLI_DEFINE_VECFUNC("cosf", "_ZGVdN8v_cosf", 8)
+TLI_DEFINE_VECFUNC("cosf", "_ZGVbN4v_cosf", FIXED(4))
+TLI_DEFINE_VECFUNC("cosf", "_ZGVdN8v_cosf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.cos.f64", "_ZGVbN2v_cos", 2)
-TLI_DEFINE_VECFUNC("llvm.cos.f64", "_ZGVdN4v_cos", 4)
+TLI_DEFINE_VECFUNC("llvm.cos.f64", "_ZGVbN2v_cos", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.cos.f64", "_ZGVdN4v_cos", FIXED(4))
 
-TLI_DEFINE_VECFUNC("llvm.cos.f32", "_ZGVbN4v_cosf", 4)
-TLI_DEFINE_VECFUNC("llvm.cos.f32", "_ZGVdN8v_cosf", 8)
+TLI_DEFINE_VECFUNC("llvm.cos.f32", "_ZGVbN4v_cosf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.cos.f32", "_ZGVdN8v_cosf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("pow", "_ZGVbN2vv_pow", 2)
-TLI_DEFINE_VECFUNC("pow", "_ZGVdN4vv_pow", 4)
+TLI_DEFINE_VECFUNC("pow", "_ZGVbN2vv_pow", FIXED(2))
+TLI_DEFINE_VECFUNC("pow", "_ZGVdN4vv_pow", FIXED(4))
 
-TLI_DEFINE_VECFUNC("powf", "_ZGVbN4vv_powf", 4)
-TLI_DEFINE_VECFUNC("powf", "_ZGVdN8vv_powf", 8)
+TLI_DEFINE_VECFUNC("powf", "_ZGVbN4vv_powf", FIXED(4))
+TLI_DEFINE_VECFUNC("powf", "_ZGVdN8vv_powf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__pow_finite", "_ZGVbN2vv___pow_finite", 2)
-TLI_DEFINE_VECFUNC("__pow_finite", "_ZGVdN4vv___pow_finite", 4)
+TLI_DEFINE_VECFUNC("__pow_finite", "_ZGVbN2vv___pow_finite", FIXED(2))
+TLI_DEFINE_VECFUNC("__pow_finite", "_ZGVdN4vv___pow_finite", FIXED(4))
 
-TLI_DEFINE_VECFUNC("__powf_finite", "_ZGVbN4vv___powf_finite", 4)
-TLI_DEFINE_VECFUNC("__powf_finite", "_ZGVdN8vv___powf_finite", 8)
+TLI_DEFINE_VECFUNC("__powf_finite", "_ZGVbN4vv___powf_finite", FIXED(4))
+TLI_DEFINE_VECFUNC("__powf_finite", "_ZGVdN8vv___powf_finite", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.pow.f64", "_ZGVbN2vv_pow", 2)
-TLI_DEFINE_VECFUNC("llvm.pow.f64", "_ZGVdN4vv_pow", 4)
+TLI_DEFINE_VECFUNC("llvm.pow.f64", "_ZGVbN2vv_pow", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.pow.f64", "_ZGVdN4vv_pow", FIXED(4))
 
-TLI_DEFINE_VECFUNC("llvm.pow.f32", "_ZGVbN4vv_powf", 4)
-TLI_DEFINE_VECFUNC("llvm.pow.f32", "_ZGVdN8vv_powf", 8)
+TLI_DEFINE_VECFUNC("llvm.pow.f32", "_ZGVbN4vv_powf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.pow.f32", "_ZGVdN8vv_powf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("exp", "_ZGVbN2v_exp", 2)
-TLI_DEFINE_VECFUNC("exp", "_ZGVdN4v_exp", 4)
+TLI_DEFINE_VECFUNC("exp", "_ZGVbN2v_exp", FIXED(2))
+TLI_DEFINE_VECFUNC("exp", "_ZGVdN4v_exp", FIXED(4))
 
-TLI_DEFINE_VECFUNC("expf", "_ZGVbN4v_expf", 4)
-TLI_DEFINE_VECFUNC("expf", "_ZGVdN8v_expf", 8)
+TLI_DEFINE_VECFUNC("expf", "_ZGVbN4v_expf", FIXED(4))
+TLI_DEFINE_VECFUNC("expf", "_ZGVdN8v_expf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__exp_finite", "_ZGVbN2v___exp_finite", 2)
-TLI_DEFINE_VECFUNC("__exp_finite", "_ZGVdN4v___exp_finite", 4)
+TLI_DEFINE_VECFUNC("__exp_finite", "_ZGVbN2v___exp_finite", FIXED(2))
+TLI_DEFINE_VECFUNC("__exp_finite", "_ZGVdN4v___exp_finite", FIXED(4))
 
-TLI_DEFINE_VECFUNC("__expf_finite", "_ZGVbN4v___expf_finite", 4)
-TLI_DEFINE_VECFUNC("__expf_finite", "_ZGVdN8v___expf_finite", 8)
+TLI_DEFINE_VECFUNC("__expf_finite", "_ZGVbN4v___expf_finite", FIXED(4))
+TLI_DEFINE_VECFUNC("__expf_finite", "_ZGVdN8v___expf_finite", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.exp.f64", "_ZGVbN2v_exp", 2)
-TLI_DEFINE_VECFUNC("llvm.exp.f64", "_ZGVdN4v_exp", 4)
+TLI_DEFINE_VECFUNC("llvm.exp.f64", "_ZGVbN2v_exp", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.exp.f64", "_ZGVdN4v_exp", FIXED(4))
 
-TLI_DEFINE_VECFUNC("llvm.exp.f32", "_ZGVbN4v_expf", 4)
-TLI_DEFINE_VECFUNC("llvm.exp.f32", "_ZGVdN8v_expf", 8)
+TLI_DEFINE_VECFUNC("llvm.exp.f32", "_ZGVbN4v_expf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp.f32", "_ZGVdN8v_expf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("log", "_ZGVbN2v_log", 2)
-TLI_DEFINE_VECFUNC("log", "_ZGVdN4v_log", 4)
+TLI_DEFINE_VECFUNC("log", "_ZGVbN2v_log", FIXED(2))
+TLI_DEFINE_VECFUNC("log", "_ZGVdN4v_log", FIXED(4))
 
-TLI_DEFINE_VECFUNC("logf", "_ZGVbN4v_logf", 4)
-TLI_DEFINE_VECFUNC("logf", "_ZGVdN8v_logf", 8)
+TLI_DEFINE_VECFUNC("logf", "_ZGVbN4v_logf", FIXED(4))
+TLI_DEFINE_VECFUNC("logf", "_ZGVdN8v_logf", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__log_finite", "_ZGVbN2v___log_finite", 2)
-TLI_DEFINE_VECFUNC("__log_finite", "_ZGVdN4v___log_finite", 4)
+TLI_DEFINE_VECFUNC("__log_finite", "_ZGVbN2v___log_finite", FIXED(2))
+TLI_DEFINE_VECFUNC("__log_finite", "_ZGVdN4v___log_finite", FIXED(4))
 
-TLI_DEFINE_VECFUNC("__logf_finite", "_ZGVbN4v___logf_finite", 4)
-TLI_DEFINE_VECFUNC("__logf_finite", "_ZGVdN8v___logf_finite", 8)
+TLI_DEFINE_VECFUNC("__logf_finite", "_ZGVbN4v___logf_finite", FIXED(4))
+TLI_DEFINE_VECFUNC("__logf_finite", "_ZGVdN8v___logf_finite", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.log.f64", "_ZGVbN2v_log", 2)
-TLI_DEFINE_VECFUNC("llvm.log.f64", "_ZGVdN4v_log", 4)
+TLI_DEFINE_VECFUNC("llvm.log.f64", "_ZGVbN2v_log", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.log.f64", "_ZGVdN4v_log", FIXED(4))
 
-TLI_DEFINE_VECFUNC("llvm.log.f32", "_ZGVbN4v_logf", 4)
-TLI_DEFINE_VECFUNC("llvm.log.f32", "_ZGVdN8v_logf", 8)
+TLI_DEFINE_VECFUNC("llvm.log.f32", "_ZGVbN4v_logf", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log.f32", "_ZGVdN8v_logf", FIXED(8))
 
 #elif defined(TLI_DEFINE_MASSV_VECFUNCS)
 // IBM MASS library's vector Functions
 
 // Floating-Point Arithmetic and Auxiliary Functions
-TLI_DEFINE_VECFUNC("cbrt", "__cbrtd2_massv", 2)
-TLI_DEFINE_VECFUNC("cbrtf", "__cbrtf4_massv", 4)
-TLI_DEFINE_VECFUNC("pow", "__powd2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.pow.f64", "__powd2_massv", 2)
-TLI_DEFINE_VECFUNC("powf", "__powf4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.pow.f32", "__powf4_massv", 4)
-TLI_DEFINE_VECFUNC("sqrt", "__sqrtd2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.sqrt.f64", "__sqrtd2_massv", 2)
-TLI_DEFINE_VECFUNC("sqrtf", "__sqrtf4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.sqrt.f32", "__sqrtf4_massv", 4)
+TLI_DEFINE_VECFUNC("cbrt", "__cbrtd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("cbrtf", "__cbrtf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("pow", "__powd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.pow.f64", "__powd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("powf", "__powf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.pow.f32", "__powf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("sqrt", "__sqrtd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.sqrt.f64", "__sqrtd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("sqrtf", "__sqrtf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.sqrt.f32", "__sqrtf4_massv", FIXED(4))
 
 // Exponential and Logarithmic Functions
-TLI_DEFINE_VECFUNC("exp", "__expd2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.exp.f64", "__expd2_massv", 2)
-TLI_DEFINE_VECFUNC("expf", "__expf4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.exp.f32", "__expf4_massv", 4)
-TLI_DEFINE_VECFUNC("exp2", "__exp2d2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__exp2d2_massv", 2)
-TLI_DEFINE_VECFUNC("exp2f", "__exp2f4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__exp2f4_massv", 4)
-TLI_DEFINE_VECFUNC("expm1", "__expm1d2_massv", 2)
-TLI_DEFINE_VECFUNC("expm1f", "__expm1f4_massv", 4)
-TLI_DEFINE_VECFUNC("log", "__logd2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.log.f64", "__logd2_massv", 2)
-TLI_DEFINE_VECFUNC("logf", "__logf4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.log.f32", "__logf4_massv", 4)
-TLI_DEFINE_VECFUNC("log1p", "__log1pd2_massv", 2)
-TLI_DEFINE_VECFUNC("log1pf", "__log1pf4_massv", 4)
-TLI_DEFINE_VECFUNC("log10", "__log10d2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.log10.f64", "__log10d2_massv", 2)
-TLI_DEFINE_VECFUNC("log10f", "__log10f4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.log10.f32", "__log10f4_massv", 4)
-TLI_DEFINE_VECFUNC("log2", "__log2d2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.log2.f64", "__log2d2_massv", 2)
-TLI_DEFINE_VECFUNC("log2f", "__log2f4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.log2.f32", "__log2f4_massv", 4)
+TLI_DEFINE_VECFUNC("exp", "__expd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.exp.f64", "__expd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("expf", "__expf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp.f32", "__expf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("exp2", "__exp2d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__exp2d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("exp2f", "__exp2f4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__exp2f4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("expm1", "__expm1d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("expm1f", "__expm1f4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("log", "__logd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.log.f64", "__logd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("logf", "__logf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log.f32", "__logf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("log1p", "__log1pd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("log1pf", "__log1pf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("log10", "__log10d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.log10.f64", "__log10d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("log10f", "__log10f4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log10.f32", "__log10f4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("log2", "__log2d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.log2.f64", "__log2d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("log2f", "__log2f4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log2.f32", "__log2f4_massv", FIXED(4))
 
 // Trigonometric Functions
-TLI_DEFINE_VECFUNC("sin", "__sind2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.sin.f64", "__sind2_massv", 2)
-TLI_DEFINE_VECFUNC("sinf", "__sinf4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.sin.f32", "__sinf4_massv", 4)
-TLI_DEFINE_VECFUNC("cos", "__cosd2_massv", 2)
-TLI_DEFINE_VECFUNC("llvm.cos.f64", "__cosd2_massv", 2)
-TLI_DEFINE_VECFUNC("cosf", "__cosf4_massv", 4)
-TLI_DEFINE_VECFUNC("llvm.cos.f32", "__cosf4_massv", 4)
-TLI_DEFINE_VECFUNC("tan", "__tand2_massv", 2)
-TLI_DEFINE_VECFUNC("tanf", "__tanf4_massv", 4)
-TLI_DEFINE_VECFUNC("asin", "__asind2_massv", 2)
-TLI_DEFINE_VECFUNC("asinf", "__asinf4_massv", 4)
-TLI_DEFINE_VECFUNC("acos", "__acosd2_massv", 2)
-TLI_DEFINE_VECFUNC("acosf", "__acosf4_massv", 4)
-TLI_DEFINE_VECFUNC("atan", "__atand2_massv", 2)
-TLI_DEFINE_VECFUNC("atanf", "__atanf4_massv", 4)
-TLI_DEFINE_VECFUNC("atan2", "__atan2d2_massv", 2)
-TLI_DEFINE_VECFUNC("atan2f", "__atan2f4_massv", 4)
+TLI_DEFINE_VECFUNC("sin", "__sind2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.sin.f64", "__sind2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("sinf", "__sinf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.sin.f32", "__sinf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("cos", "__cosd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.cos.f64", "__cosd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("cosf", "__cosf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.cos.f32", "__cosf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("tan", "__tand2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("tanf", "__tanf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("asin", "__asind2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("asinf", "__asinf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("acos", "__acosd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("acosf", "__acosf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("atan", "__atand2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("atanf", "__atanf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("atan2", "__atan2d2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("atan2f", "__atan2f4_massv", FIXED(4))
 
 // Hyperbolic Functions
-TLI_DEFINE_VECFUNC("sinh", "__sinhd2_massv", 2)
-TLI_DEFINE_VECFUNC("sinhf", "__sinhf4_massv", 4)
-TLI_DEFINE_VECFUNC("cosh", "__coshd2_massv", 2)
-TLI_DEFINE_VECFUNC("coshf", "__coshf4_massv", 4)
-TLI_DEFINE_VECFUNC("tanh", "__tanhd2_massv", 2)
-TLI_DEFINE_VECFUNC("tanhf", "__tanhf4_massv", 4)
-TLI_DEFINE_VECFUNC("asinh", "__asinhd2_massv", 2)
-TLI_DEFINE_VECFUNC("asinhf", "__asinhf4_massv", 4)
-TLI_DEFINE_VECFUNC("acosh", "__acoshd2_massv", 2)
-TLI_DEFINE_VECFUNC("acoshf", "__acoshf4_massv", 4)
-TLI_DEFINE_VECFUNC("atanh", "__atanhd2_massv", 2)
-TLI_DEFINE_VECFUNC("atanhf", "__atanhf4_massv", 4)
+TLI_DEFINE_VECFUNC("sinh", "__sinhd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("sinhf", "__sinhf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("cosh", "__coshd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("coshf", "__coshf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("tanh", "__tanhd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("tanhf", "__tanhf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("asinh", "__asinhd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("asinhf", "__asinhf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("acosh", "__acoshd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("acoshf", "__acoshf4_massv", FIXED(4))
+TLI_DEFINE_VECFUNC("atanh", "__atanhd2_massv", FIXED(2))
+TLI_DEFINE_VECFUNC("atanhf", "__atanhf4_massv", FIXED(4))
 
 
 #elif defined(TLI_DEFINE_SVML_VECFUNCS)
 // Intel SVM library's Vector Functions
 
-TLI_DEFINE_VECFUNC("sin", "__svml_sin2", 2)
-TLI_DEFINE_VECFUNC("sin", "__svml_sin4", 4)
-TLI_DEFINE_VECFUNC("sin", "__svml_sin8", 8)
+TLI_DEFINE_VECFUNC("sin", "__svml_sin2", FIXED(2))
+TLI_DEFINE_VECFUNC("sin", "__svml_sin4", FIXED(4))
+TLI_DEFINE_VECFUNC("sin", "__svml_sin8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("sinf", "__svml_sinf4", 4)
-TLI_DEFINE_VECFUNC("sinf", "__svml_sinf8", 8)
-TLI_DEFINE_VECFUNC("sinf", "__svml_sinf16", 16)
+TLI_DEFINE_VECFUNC("sinf", "__svml_sinf4", FIXED(4))
+TLI_DEFINE_VECFUNC("sinf", "__svml_sinf8", FIXED(8))
+TLI_DEFINE_VECFUNC("sinf", "__svml_sinf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin2", 2)
-TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin4", 4)
-TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin8", 8)
+TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin2", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.sin.f64", "__svml_sin8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf4", 4)
-TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf8", 8)
-TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf16", 16)
+TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.sin.f32", "__svml_sinf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("cos", "__svml_cos2", 2)
-TLI_DEFINE_VECFUNC("cos", "__svml_cos4", 4)
-TLI_DEFINE_VECFUNC("cos", "__svml_cos8", 8)
+TLI_DEFINE_VECFUNC("cos", "__svml_cos2", FIXED(2))
+TLI_DEFINE_VECFUNC("cos", "__svml_cos4", FIXED(4))
+TLI_DEFINE_VECFUNC("cos", "__svml_cos8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("cosf", "__svml_cosf4", 4)
-TLI_DEFINE_VECFUNC("cosf", "__svml_cosf8", 8)
-TLI_DEFINE_VECFUNC("cosf", "__svml_cosf16", 16)
+TLI_DEFINE_VECFUNC("cosf", "__svml_cosf4", FIXED(4))
+TLI_DEFINE_VECFUNC("cosf", "__svml_cosf8", FIXED(8))
+TLI_DEFINE_VECFUNC("cosf", "__svml_cosf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos2", 2)
-TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos4", 4)
-TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos8", 8)
+TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos2", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.cos.f64", "__svml_cos8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf4", 4)
-TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf8", 8)
-TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf16", 16)
+TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.cos.f32", "__svml_cosf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("pow", "__svml_pow2", 2)
-TLI_DEFINE_VECFUNC("pow", "__svml_pow4", 4)
-TLI_DEFINE_VECFUNC("pow", "__svml_pow8", 8)
+TLI_DEFINE_VECFUNC("pow", "__svml_pow2", FIXED(2))
+TLI_DEFINE_VECFUNC("pow", "__svml_pow4", FIXED(4))
+TLI_DEFINE_VECFUNC("pow", "__svml_pow8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("powf", "__svml_powf4", 4)
-TLI_DEFINE_VECFUNC("powf", "__svml_powf8", 8)
-TLI_DEFINE_VECFUNC("powf", "__svml_powf16", 16)
+TLI_DEFINE_VECFUNC("powf", "__svml_powf4", FIXED(4))
+TLI_DEFINE_VECFUNC("powf", "__svml_powf8", FIXED(8))
+TLI_DEFINE_VECFUNC("powf", "__svml_powf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow2", 2)
-TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow4", 4)
-TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow8", 8)
+TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow2", FIXED(2))
+TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow4", FIXED(4))
+TLI_DEFINE_VECFUNC("__pow_finite", "__svml_pow8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf4", 4)
-TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf8", 8)
-TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf16", 16)
+TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf4", FIXED(4))
+TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf8", FIXED(8))
+TLI_DEFINE_VECFUNC("__powf_finite", "__svml_powf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow2", 2)
-TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow4", 4)
-TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow8", 8)
+TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow2", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.pow.f64", "__svml_pow8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf4", 4)
-TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf8", 8)
-TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf16", 16)
+TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.pow.f32", "__svml_powf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("exp", "__svml_exp2", 2)
-TLI_DEFINE_VECFUNC("exp", "__svml_exp4", 4)
-TLI_DEFINE_VECFUNC("exp", "__svml_exp8", 8)
+TLI_DEFINE_VECFUNC("exp", "__svml_exp2", FIXED(2))
+TLI_DEFINE_VECFUNC("exp", "__svml_exp4", FIXED(4))
+TLI_DEFINE_VECFUNC("exp", "__svml_exp8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("expf", "__svml_expf4", 4)
-TLI_DEFINE_VECFUNC("expf", "__svml_expf8", 8)
-TLI_DEFINE_VECFUNC("expf", "__svml_expf16", 16)
+TLI_DEFINE_VECFUNC("expf", "__svml_expf4", FIXED(4))
+TLI_DEFINE_VECFUNC("expf", "__svml_expf8", FIXED(8))
+TLI_DEFINE_VECFUNC("expf", "__svml_expf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp2", 2)
-TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp4", 4)
-TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp8", 8)
+TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp2", FIXED(2))
+TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp4", FIXED(4))
+TLI_DEFINE_VECFUNC("__exp_finite", "__svml_exp8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf4", 4)
-TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf8", 8)
-TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf16", 16)
+TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf4", FIXED(4))
+TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf8", FIXED(8))
+TLI_DEFINE_VECFUNC("__expf_finite", "__svml_expf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp2", 2)
-TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp4", 4)
-TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp8", 8)
+TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp2", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp.f64", "__svml_exp8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf4", 4)
-TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf8", 8)
-TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf16", 16)
+TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.exp.f32", "__svml_expf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("log", "__svml_log2", 2)
-TLI_DEFINE_VECFUNC("log", "__svml_log4", 4)
-TLI_DEFINE_VECFUNC("log", "__svml_log8", 8)
+TLI_DEFINE_VECFUNC("log", "__svml_log2", FIXED(2))
+TLI_DEFINE_VECFUNC("log", "__svml_log4", FIXED(4))
+TLI_DEFINE_VECFUNC("log", "__svml_log8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("logf", "__svml_logf4", 4)
-TLI_DEFINE_VECFUNC("logf", "__svml_logf8", 8)
-TLI_DEFINE_VECFUNC("logf", "__svml_logf16", 16)
+TLI_DEFINE_VECFUNC("logf", "__svml_logf4", FIXED(4))
+TLI_DEFINE_VECFUNC("logf", "__svml_logf8", FIXED(8))
+TLI_DEFINE_VECFUNC("logf", "__svml_logf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("__log_finite", "__svml_log2", 2)
-TLI_DEFINE_VECFUNC("__log_finite", "__svml_log4", 4)
-TLI_DEFINE_VECFUNC("__log_finite", "__svml_log8", 8)
+TLI_DEFINE_VECFUNC("__log_finite", "__svml_log2", FIXED(2))
+TLI_DEFINE_VECFUNC("__log_finite", "__svml_log4", FIXED(4))
+TLI_DEFINE_VECFUNC("__log_finite", "__svml_log8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf4", 4)
-TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf8", 8)
-TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf16", 16)
+TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf4", FIXED(4))
+TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf8", FIXED(8))
+TLI_DEFINE_VECFUNC("__logf_finite", "__svml_logf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log2", 2)
-TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log4", 4)
-TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log8", 8)
+TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log2", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log.f64", "__svml_log8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf4", 4)
-TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf8", 8)
-TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf16", 16)
+TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.log.f32", "__svml_logf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("log2", "__svml_log22", 2)
-TLI_DEFINE_VECFUNC("log2", "__svml_log24", 4)
-TLI_DEFINE_VECFUNC("log2", "__svml_log28", 8)
+TLI_DEFINE_VECFUNC("log2", "__svml_log22", FIXED(2))
+TLI_DEFINE_VECFUNC("log2", "__svml_log24", FIXED(4))
+TLI_DEFINE_VECFUNC("log2", "__svml_log28", FIXED(8))
 
-TLI_DEFINE_VECFUNC("log2f", "__svml_log2f4", 4)
-TLI_DEFINE_VECFUNC("log2f", "__svml_log2f8", 8)
-TLI_DEFINE_VECFUNC("log2f", "__svml_log2f16", 16)
+TLI_DEFINE_VECFUNC("log2f", "__svml_log2f4", FIXED(4))
+TLI_DEFINE_VECFUNC("log2f", "__svml_log2f8", FIXED(8))
+TLI_DEFINE_VECFUNC("log2f", "__svml_log2f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("__log2_finite", "__svml_log22", 2)
-TLI_DEFINE_VECFUNC("__log2_finite", "__svml_log24", 4)
-TLI_DEFINE_VECFUNC("__log2_finite", "__svml_log28", 8)
+TLI_DEFINE_VECFUNC("__log2_finite", "__svml_log22", FIXED(2))
+TLI_DEFINE_VECFUNC("__log2_finite", "__svml_log24", FIXED(4))
+TLI_DEFINE_VECFUNC("__log2_finite", "__svml_log28", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__log2f_finite", "__svml_log2f4", 4)
-TLI_DEFINE_VECFUNC("__log2f_finite", "__svml_log2f8", 8)
-TLI_DEFINE_VECFUNC("__log2f_finite", "__svml_log2f16", 16)
+TLI_DEFINE_VECFUNC("__log2f_finite", "__svml_log2f4", FIXED(4))
+TLI_DEFINE_VECFUNC("__log2f_finite", "__svml_log2f8", FIXED(8))
+TLI_DEFINE_VECFUNC("__log2f_finite", "__svml_log2f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.log2.f64", "__svml_log22", 2)
-TLI_DEFINE_VECFUNC("llvm.log2.f64", "__svml_log24", 4)
-TLI_DEFINE_VECFUNC("llvm.log2.f64", "__svml_log28", 8)
+TLI_DEFINE_VECFUNC("llvm.log2.f64", "__svml_log22", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.log2.f64", "__svml_log24", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log2.f64", "__svml_log28", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.log2.f32", "__svml_log2f4", 4)
-TLI_DEFINE_VECFUNC("llvm.log2.f32", "__svml_log2f8", 8)
-TLI_DEFINE_VECFUNC("llvm.log2.f32", "__svml_log2f16", 16)
+TLI_DEFINE_VECFUNC("llvm.log2.f32", "__svml_log2f4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log2.f32", "__svml_log2f8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.log2.f32", "__svml_log2f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("log10", "__svml_log102", 2)
-TLI_DEFINE_VECFUNC("log10", "__svml_log104", 4)
-TLI_DEFINE_VECFUNC("log10", "__svml_log108", 8)
+TLI_DEFINE_VECFUNC("log10", "__svml_log102", FIXED(2))
+TLI_DEFINE_VECFUNC("log10", "__svml_log104", FIXED(4))
+TLI_DEFINE_VECFUNC("log10", "__svml_log108", FIXED(8))
 
-TLI_DEFINE_VECFUNC("log10f", "__svml_log10f4", 4)
-TLI_DEFINE_VECFUNC("log10f", "__svml_log10f8", 8)
-TLI_DEFINE_VECFUNC("log10f", "__svml_log10f16", 16)
+TLI_DEFINE_VECFUNC("log10f", "__svml_log10f4", FIXED(4))
+TLI_DEFINE_VECFUNC("log10f", "__svml_log10f8", FIXED(8))
+TLI_DEFINE_VECFUNC("log10f", "__svml_log10f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("__log10_finite", "__svml_log102", 2)
-TLI_DEFINE_VECFUNC("__log10_finite", "__svml_log104", 4)
-TLI_DEFINE_VECFUNC("__log10_finite", "__svml_log108", 8)
+TLI_DEFINE_VECFUNC("__log10_finite", "__svml_log102", FIXED(2))
+TLI_DEFINE_VECFUNC("__log10_finite", "__svml_log104", FIXED(4))
+TLI_DEFINE_VECFUNC("__log10_finite", "__svml_log108", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__log10f_finite", "__svml_log10f4", 4)
-TLI_DEFINE_VECFUNC("__log10f_finite", "__svml_log10f8", 8)
-TLI_DEFINE_VECFUNC("__log10f_finite", "__svml_log10f16", 16)
+TLI_DEFINE_VECFUNC("__log10f_finite", "__svml_log10f4", FIXED(4))
+TLI_DEFINE_VECFUNC("__log10f_finite", "__svml_log10f8", FIXED(8))
+TLI_DEFINE_VECFUNC("__log10f_finite", "__svml_log10f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.log10.f64", "__svml_log102", 2)
-TLI_DEFINE_VECFUNC("llvm.log10.f64", "__svml_log104", 4)
-TLI_DEFINE_VECFUNC("llvm.log10.f64", "__svml_log108", 8)
+TLI_DEFINE_VECFUNC("llvm.log10.f64", "__svml_log102", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.log10.f64", "__svml_log104", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log10.f64", "__svml_log108", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.log10.f32", "__svml_log10f4", 4)
-TLI_DEFINE_VECFUNC("llvm.log10.f32", "__svml_log10f8", 8)
-TLI_DEFINE_VECFUNC("llvm.log10.f32", "__svml_log10f16", 16)
+TLI_DEFINE_VECFUNC("llvm.log10.f32", "__svml_log10f4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.log10.f32", "__svml_log10f8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.log10.f32", "__svml_log10f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("sqrt", "__svml_sqrt2", 2)
-TLI_DEFINE_VECFUNC("sqrt", "__svml_sqrt4", 4)
-TLI_DEFINE_VECFUNC("sqrt", "__svml_sqrt8", 8)
+TLI_DEFINE_VECFUNC("sqrt", "__svml_sqrt2", FIXED(2))
+TLI_DEFINE_VECFUNC("sqrt", "__svml_sqrt4", FIXED(4))
+TLI_DEFINE_VECFUNC("sqrt", "__svml_sqrt8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("sqrtf", "__svml_sqrtf4", 4)
-TLI_DEFINE_VECFUNC("sqrtf", "__svml_sqrtf8", 8)
-TLI_DEFINE_VECFUNC("sqrtf", "__svml_sqrtf16", 16)
+TLI_DEFINE_VECFUNC("sqrtf", "__svml_sqrtf4", FIXED(4))
+TLI_DEFINE_VECFUNC("sqrtf", "__svml_sqrtf8", FIXED(8))
+TLI_DEFINE_VECFUNC("sqrtf", "__svml_sqrtf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("__sqrt_finite", "__svml_sqrt2", 2)
-TLI_DEFINE_VECFUNC("__sqrt_finite", "__svml_sqrt4", 4)
-TLI_DEFINE_VECFUNC("__sqrt_finite", "__svml_sqrt8", 8)
+TLI_DEFINE_VECFUNC("__sqrt_finite", "__svml_sqrt2", FIXED(2))
+TLI_DEFINE_VECFUNC("__sqrt_finite", "__svml_sqrt4", FIXED(4))
+TLI_DEFINE_VECFUNC("__sqrt_finite", "__svml_sqrt8", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__sqrtf_finite", "__svml_sqrtf4", 4)
-TLI_DEFINE_VECFUNC("__sqrtf_finite", "__svml_sqrtf8", 8)
-TLI_DEFINE_VECFUNC("__sqrtf_finite", "__svml_sqrtf16", 16)
+TLI_DEFINE_VECFUNC("__sqrtf_finite", "__svml_sqrtf4", FIXED(4))
+TLI_DEFINE_VECFUNC("__sqrtf_finite", "__svml_sqrtf8", FIXED(8))
+TLI_DEFINE_VECFUNC("__sqrtf_finite", "__svml_sqrtf16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("exp2", "__svml_exp22", 2)
-TLI_DEFINE_VECFUNC("exp2", "__svml_exp24", 4)
-TLI_DEFINE_VECFUNC("exp2", "__svml_exp28", 8)
+TLI_DEFINE_VECFUNC("exp2", "__svml_exp22", FIXED(2))
+TLI_DEFINE_VECFUNC("exp2", "__svml_exp24", FIXED(4))
+TLI_DEFINE_VECFUNC("exp2", "__svml_exp28", FIXED(8))
 
-TLI_DEFINE_VECFUNC("exp2f", "__svml_exp2f4", 4)
-TLI_DEFINE_VECFUNC("exp2f", "__svml_exp2f8", 8)
-TLI_DEFINE_VECFUNC("exp2f", "__svml_exp2f16", 16)
+TLI_DEFINE_VECFUNC("exp2f", "__svml_exp2f4", FIXED(4))
+TLI_DEFINE_VECFUNC("exp2f", "__svml_exp2f8", FIXED(8))
+TLI_DEFINE_VECFUNC("exp2f", "__svml_exp2f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__svml_exp22", 2)
-TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__svml_exp24", 4)
-TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__svml_exp28", 8)
+TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__svml_exp22", FIXED(2))
+TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__svml_exp24", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp2.f64", "__svml_exp28", FIXED(8))
 
-TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__svml_exp2f4", 4)
-TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__svml_exp2f8", 8)
-TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__svml_exp2f16", 16)
+TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__svml_exp2f4", FIXED(4))
+TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__svml_exp2f8", FIXED(8))
+TLI_DEFINE_VECFUNC("llvm.exp2.f32", "__svml_exp2f16", FIXED(16))
 
-TLI_DEFINE_VECFUNC("__exp2_finite", "__svml_exp22", 2)
-TLI_DEFINE_VECFUNC("__exp2_finite", "__svml_exp24", 4)
-TLI_DEFINE_VECFUNC("__exp2_finite", "__svml_exp28", 8)
+TLI_DEFINE_VECFUNC("__exp2_finite", "__svml_exp22", FIXED(2))
+TLI_DEFINE_VECFUNC("__exp2_finite", "__svml_exp24", FIXED(4))
+TLI_DEFINE_VECFUNC("__exp2_finite", "__svml_exp28", FIXED(8))
 
-TLI_DEFINE_VECFUNC("__exp2f_finite", "__svml_exp2f4", 4)
-TLI_DEFINE_VECFUNC("__exp2f_finite", "__svml_exp2f8", 8)
-TLI_DEFINE_VECFUNC("__exp2f_finite", "__svml_exp2f16", 16)
+TLI_DEFINE_VECFUNC("__exp2f_finite", "__svml_exp2f4", FIXED(4))
+TLI_DEFINE_VECFUNC("__exp2f_finite", "__svml_exp2f8", FIXED(8))
+TLI_DEFINE_VECFUNC("__exp2f_finite", "__svml_exp2f16", FIXED(16))
 
 #else
 #error "Must choose which vector library functions are to be defined."

diff  --git a/llvm/include/llvm/Support/TypeSize.h b/llvm/include/llvm/Support/TypeSize.h
index 6d824a439ded..72589693a4df 100644
--- a/llvm/include/llvm/Support/TypeSize.h
+++ b/llvm/include/llvm/Support/TypeSize.h
@@ -381,6 +381,7 @@ template <> struct LinearPolyBaseTypeTraits<ElementCount> {
 
 class ElementCount : public LinearPolySize<ElementCount> {
 public:
+  ElementCount() : LinearPolySize(LinearPolySize::getNull()) {}
 
   ElementCount(const LinearPolySize<ElementCount> &V) : LinearPolySize(V) {}
 

diff  --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index c85b122b0dab..1a50cac3a765 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -1608,8 +1608,9 @@ bool TargetLibraryInfoImpl::isFunctionVectorizable(StringRef funcName) const {
   return I != VectorDescs.end() && StringRef(I->ScalarFnName) == funcName;
 }
 
-StringRef TargetLibraryInfoImpl::getVectorizedFunction(StringRef F,
-                                                       unsigned VF) const {
+StringRef
+TargetLibraryInfoImpl::getVectorizedFunction(StringRef F,
+                                             const ElementCount &VF) const {
   F = sanitizeFunctionName(F);
   if (F.empty())
     return F;
@@ -1663,18 +1664,24 @@ char TargetLibraryInfoWrapperPass::ID = 0;
 
 void TargetLibraryInfoWrapperPass::anchor() {}
 
-unsigned TargetLibraryInfoImpl::getWidestVF(StringRef ScalarF) const {
+void TargetLibraryInfoImpl::getWidestVF(StringRef ScalarF,
+                                        ElementCount &FixedVF,
+                                        ElementCount &ScalableVF) const {
   ScalarF = sanitizeFunctionName(ScalarF);
+  // Use '0' here because a type of the form <vscale x 1 x ElTy> is not the
+  // same as a scalar.
+  ScalableVF = ElementCount::getScalable(0);
+  FixedVF = ElementCount::getFixed(1);
   if (ScalarF.empty())
-    return 1;
+    return;
 
-  unsigned VF = 1;
   std::vector<VecDesc>::const_iterator I =
       llvm::lower_bound(VectorDescs, ScalarF, compareWithScalarFnName);
   while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == ScalarF) {
-    if (I->VectorizationFactor > VF)
-      VF = I->VectorizationFactor;
+    ElementCount *VF =
+        I->VectorizationFactor.isScalable() ? &ScalableVF : &FixedVF;
+    if (ElementCount::isKnownGT(I->VectorizationFactor, *VF))
+      *VF = I->VectorizationFactor;
     ++I;
   }
-  return VF;
 }

diff  --git a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
index 42c49b7f5dc7..a1e160d144dc 100644
--- a/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ b/llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -40,7 +40,7 @@ STATISTIC(NumCompUsedAdded,
 /// lanes. The TLI assumes that all parameters and the return type of
 /// CI (other than void) need to be widened to a VectorType of VF
 /// lanes.
-static void addVariantDeclaration(CallInst &CI, const unsigned VF,
+static void addVariantDeclaration(CallInst &CI, const ElementCount &VF,
                                   const StringRef VFName) {
   Module *M = CI.getModule();
 
@@ -89,15 +89,13 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
   Module *M = CI.getModule();
   const SetVector<StringRef> OriginalSetOfMappings(Mappings.begin(),
                                                    Mappings.end());
-  //  All VFs in the TLI are powers of 2.
-  for (unsigned VF = 2, WidestVF = TLI.getWidestVF(ScalarName); VF <= WidestVF;
-       VF *= 2) {
+
+  auto AddVariantDecl = [&](const ElementCount &VF) {
     const std::string TLIName =
         std::string(TLI.getVectorizedFunction(ScalarName, VF));
     if (!TLIName.empty()) {
       std::string MangledName = VFABI::mangleTLIVectorName(
-          TLIName, ScalarName, CI.getNumArgOperands(),
-          ElementCount::getFixed(VF));
+          TLIName, ScalarName, CI.getNumArgOperands(), VF);
       if (!OriginalSetOfMappings.count(MangledName)) {
         Mappings.push_back(MangledName);
         ++NumCallInjected;
@@ -106,7 +104,19 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) {
       if (!VariantF)
         addVariantDeclaration(CI, VF, TLIName);
     }
-  }
+  };
+
+  //  All VFs in the TLI are powers of 2.
+  ElementCount WidestFixedVF, WidestScalableVF;
+  TLI.getWidestVF(ScalarName, WidestFixedVF, WidestScalableVF);
+
+  for (ElementCount VF = ElementCount::getFixed(2);
+       ElementCount::isKnownLE(VF, WidestFixedVF); VF *= 2)
+    AddVariantDecl(VF);
+
+  // TODO: Add scalable variants once we're able to test them.
+  assert(WidestScalableVF.isZero() &&
+         "Scalable vector mappings not yet supported");
 
   VFABI::setVectorVariantNames(&CI, Mappings);
 }

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 2e35dfa66a18..1b03276f8e39 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -594,11 +594,18 @@ static bool isTLIScalarize(const TargetLibraryInfo &TLI, const CallInst &CI) {
   bool Scalarize = TLI.isFunctionVectorizable(ScalarName);
   // Check that all known VFs are not associated to a vector
   // function, i.e. the vector name is emty.
-  if (Scalarize)
-    for (unsigned VF = 2, WidestVF = TLI.getWidestVF(ScalarName);
-         VF <= WidestVF; VF *= 2) {
+  if (Scalarize) {
+    ElementCount WidestFixedVF, WidestScalableVF;
+    TLI.getWidestVF(ScalarName, WidestFixedVF, WidestScalableVF);
+    for (ElementCount VF = ElementCount::getFixed(2);
+         ElementCount::isKnownLE(VF, WidestFixedVF); VF *= 2)
       Scalarize &= !TLI.isFunctionVectorizable(ScalarName, VF);
-    }
+    for (ElementCount VF = ElementCount::getScalable(1);
+         ElementCount::isKnownLE(VF, WidestScalableVF); VF *= 2)
+      Scalarize &= !TLI.isFunctionVectorizable(ScalarName, VF);
+    assert((WidestScalableVF.isZero() || !Scalarize) &&
+           "Caller may decide to scalarize a variant using a scalable VF");
+  }
   return Scalarize;
 }
 


        


More information about the llvm-commits mailing list