[PATCH] D30680: new method TargetTransformInfo::supportsVectorElementLoadStore() for LoopVectorizer
Jonas Paulsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 23:49:55 PST 2017
jonpa created this revision.
Herald added a subscriber: mzolotukhin.
Since SystemZ supports vector element load / store instructions, there is no need for extracts / inserts if a vector load / store gets scalarized. This patch lets Target specify that it supports such instructions by means of a new TTI virtual method that defaults to false.
The use for this is in the LoopVectorizer getScalarizationOverhead() method. As a side note, I am thinking perhaps this function should go into BasicTTIImpl.h, but since there are a at least two changes in review in this area, I am waiting with that.
https://reviews.llvm.org/D30680
Files:
include/llvm/Analysis/TargetTransformInfo.h
include/llvm/Analysis/TargetTransformInfoImpl.h
lib/Analysis/TargetTransformInfo.cpp
lib/Target/SystemZ/SystemZTargetTransformInfo.h
lib/Transforms/Vectorize/LoopVectorize.cpp
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3723,13 +3723,15 @@
unsigned Cost = 0;
Type *RetTy = ToVectorTy(I->getType(), VF);
- if (!RetTy->isVoidTy())
+ if (!RetTy->isVoidTy() &&
+ (!isa<LoadInst>(I) || !TTI.supportsVectorElementLoadStore()))
Cost += TTI.getScalarizationOverhead(RetTy, true, false);
if (CallInst *CI = dyn_cast<CallInst>(I)) {
SmallVector<const Value *, 4> Operands(CI->arg_operands());
Cost += TTI.getOperandsScalarizationOverhead(Operands, VF);
- } else {
+ }
+ else if (!isa<StoreInst>(I) || !TTI.supportsVectorElementLoadStore()) {
SmallVector<const Value *, 4> Operands(I->operand_values());
Cost += TTI.getOperandsScalarizationOverhead(Operands, VF);
}
Index: lib/Target/SystemZ/SystemZTargetTransformInfo.h
===================================================================
--- lib/Target/SystemZ/SystemZTargetTransformInfo.h
+++ lib/Target/SystemZ/SystemZTargetTransformInfo.h
@@ -55,6 +55,8 @@
unsigned getNumberOfRegisters(bool Vector);
unsigned getRegisterBitWidth(bool Vector);
+ bool supportsVectorElementLoadStore() { return true; }
+
bool isFPVectorizationPotentiallyUnsafe() { return false; }
int getArithmeticInstrCost(
Index: lib/Analysis/TargetTransformInfo.cpp
===================================================================
--- lib/Analysis/TargetTransformInfo.cpp
+++ lib/Analysis/TargetTransformInfo.cpp
@@ -197,6 +197,10 @@
return TTIImpl->getOperandsScalarizationOverhead(Args, VF, VecTy);
}
+bool TargetTransformInfo::supportsVectorElementLoadStore() const {
+ return TTIImpl->supportsVectorElementLoadStore();
+}
+
bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
}
Index: include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- include/llvm/Analysis/TargetTransformInfoImpl.h
+++ include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -262,6 +262,8 @@
unsigned getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
unsigned VF, Type *VecTy) { return 0; }
+ bool supportsVectorElementLoadStore() { return false; }
+
bool enableAggressiveInterleaving(bool LoopHasReductions) { return false; }
bool enableInterleavedAccessVectorization() { return false; }
Index: include/llvm/Analysis/TargetTransformInfo.h
===================================================================
--- include/llvm/Analysis/TargetTransformInfo.h
+++ include/llvm/Analysis/TargetTransformInfo.h
@@ -434,6 +434,8 @@
unsigned getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
unsigned VF, Type *VecTy = nullptr) const;
+ bool supportsVectorElementLoadStore() const;
+
/// \brief Don't restrict interleaved unrolling to small loops.
bool enableAggressiveInterleaving(bool LoopHasReductions) const;
@@ -775,6 +777,7 @@
getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) = 0;
virtual unsigned getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
unsigned VF, Type *VecTy) = 0;
+ virtual bool supportsVectorElementLoadStore() = 0;
virtual bool enableAggressiveInterleaving(bool LoopHasReductions) = 0;
virtual bool enableInterleavedAccessVectorization() = 0;
virtual bool isFPVectorizationPotentiallyUnsafe() = 0;
@@ -980,6 +983,10 @@
return Impl.getOperandsScalarizationOverhead(Args, VF, VecTy);
}
+ bool supportsVectorElementLoadStore() override {
+ return Impl.supportsVectorElementLoadStore();
+ }
+
bool enableAggressiveInterleaving(bool LoopHasReductions) override {
return Impl.enableAggressiveInterleaving(LoopHasReductions);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30680.90801.patch
Type: text/x-patch
Size: 4010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170307/5fac75be/attachment.bin>
More information about the llvm-commits
mailing list