[llvm-commits] [Review Request][Patch]Introduce the VectorizeConfig class.
Hongbin Zheng
etherzhhb at gmail.com
Thu Apr 5 20:56:44 PDT 2012
hi all,
On Fri, Apr 6, 2012 at 12:44 AM, Hal Finkel <hfinkel at anl.gov> wrote:
> Makes sense to me. Thanks, Sebastian!
>
> -Hal
>
> On Thu, 5 Apr 2012 11:42:20 -0500
> Sebastian Pop <spop at codeaurora.org> wrote:
>
>> On Thu, Apr 5, 2012 at 11:37 AM, Sebastian Pop <spop at codeaurora.org>
>> wrote:
>> > Please avoid the negative field names: instead please use the
>> > positive...
>>
I think i can clean this up:
---
include/llvm/Transforms/Vectorize.h | 24 ++++++++++++------------
lib/Transforms/Vectorize/BBVectorize.cpp | 28 +++++++++++++++-------------
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/include/llvm/Transforms/Vectorize.h
b/include/llvm/Transforms/Vectorize.h
index 6691258..7701ceb 100644
--- a/include/llvm/Transforms/Vectorize.h
+++ b/include/llvm/Transforms/Vectorize.h
@@ -28,23 +28,23 @@ struct VectorizeConfig {
/// @brief The size of the native vector registers.
unsigned VectorBits;
- /// @brief Don't try to vectorize integer values.
- bool NoInts;
+ /// @brief Vectorize integer values.
+ bool VectorizeInts;
- /// @brief Don't try to vectorize floating-point values.
- bool NoFloats;
+ /// @brief Vectorize floating-point values.
+ bool VectorizeFloats;
- /// @brief Don't try to vectorize casting (conversion) operations.
- bool NoCasts;
+ /// @brief Vectorize casting (conversion) operations.
+ bool VectorizeCasts;
- /// @brief Don't try to vectorize floating-point math intrinsics.
- bool NoMath;
+ /// @brief Vectorize floating-point math intrinsics.
+ bool VectorizeMath;
- /// @brief Don't try to vectorize the fused-multiply-add intrinsic.
- bool NoFMA;
+ /// @brief Vectorize the fused-multiply-add intrinsic.
+ bool VectorizeFMA;
- /// @brief Don't try to vectorize loads and stores.
- bool NoMemOps;
+ /// @brief Vectorize loads and stores.
+ bool VectorizeMemOps;
/// @brief Only generate aligned loads and stores.
bool AlignedOnly;
diff --git a/lib/Transforms/Vectorize/BBVectorize.cpp
b/lib/Transforms/Vectorize/BBVectorize.cpp
index 82be697..286b54f 100644
--- a/lib/Transforms/Vectorize/BBVectorize.cpp
+++ b/lib/Transforms/Vectorize/BBVectorize.cpp
@@ -437,9 +437,9 @@ namespace {
case Intrinsic::exp:
case Intrinsic::exp2:
case Intrinsic::pow:
- return !Config.NoMath;
+ return Config.VectorizeMath;
case Intrinsic::fma:
- return !Config.NoFMA;
+ return Config.VectorizeFMA;
}
}
@@ -533,16 +533,16 @@ namespace {
} else if (LoadInst *L = dyn_cast<LoadInst>(I)) {
// Vectorize simple loads if possbile:
IsSimpleLoadStore = L->isSimple();
- if (!IsSimpleLoadStore || Config.NoMemOps)
+ if (!IsSimpleLoadStore || !Config.VectorizeMemOps)
return false;
} else if (StoreInst *S = dyn_cast<StoreInst>(I)) {
// Vectorize simple stores if possbile:
IsSimpleLoadStore = S->isSimple();
- if (!IsSimpleLoadStore || Config.NoMemOps)
+ if (!IsSimpleLoadStore || !Config.VectorizeMemOps)
return false;
} else if (CastInst *C = dyn_cast<CastInst>(I)) {
// We can vectorize casts, but not casts of pointer types, etc.
- if (Config.NoCasts)
+ if (!Config.VectorizeCasts)
return false;
Type *SrcTy = C->getSrcTy();
@@ -582,10 +582,12 @@ namespace {
!(VectorType::isValidElementType(T2) || T2->isVectorTy()))
return false;
- if (Config.NoInts && (T1->isIntOrIntVectorTy() ||
T2->isIntOrIntVectorTy()))
+ if (!Config.VectorizeInts
+ && (T1->isIntOrIntVectorTy() || T2->isIntOrIntVectorTy()))
return false;
- if (Config.NoFloats && (T1->isFPOrFPVectorTy() || T2->isFPOrFPVectorTy()))
+ if (!Config.VectorizeFloats
+ && (T1->isFPOrFPVectorTy() || T2->isFPOrFPVectorTy()))
return false;
if (T1->getPrimitiveSizeInBits() > Config.VectorBits/2 ||
@@ -1887,12 +1889,12 @@ llvm::vectorizeBasicBlock(Pass *P, BasicBlock
&BB, const VectorizeConfig &C) {
//===----------------------------------------------------------------------===//
VectorizeConfig::VectorizeConfig() {
VectorBits = ::VectorBits;
- NoInts = ::NoInts;
- NoFloats = ::NoFloats;
- NoCasts = ::NoCasts;
- NoMath = ::NoMath;
- NoFMA = ::NoFMA;
- NoMemOps = ::NoMemOps;
+ VectorizeInts = !::NoInts;
+ VectorizeFloats = !::NoFloats;
+ VectorizeCasts = !::NoCasts;
+ VectorizeMath = !::NoMath;
+ VectorizeFMA = !::NoFMA;
+ VectorizeMemOps = !::NoMemOps;
AlignedOnly = ::AlignedOnly;
ReqChainDepth= ::ReqChainDepth;
SearchLimit = ::SearchLimit;
--
1.7.5.4
More information about the llvm-commits
mailing list