summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/CostModel.cpp
diff options
context:
space:
mode:
authorMichael Kuperstein <mkuper@google.com>2016-08-04 22:48:03 +0000
committerMichael Kuperstein <mkuper@google.com>2016-08-04 22:48:03 +0000
commit3ceac2bbd5e48a3e7d90b7344d45d9f7cf3106a5 (patch)
tree6ae8ac6b6ffc55fa5e76436031397a45b035ca96 /llvm/lib/Analysis/CostModel.cpp
parent742c38361bfcf53561c0fca9289abbda03a5f40b (diff)
downloadbcm5719-llvm-3ceac2bbd5e48a3e7d90b7344d45d9f7cf3106a5.tar.gz
bcm5719-llvm-3ceac2bbd5e48a3e7d90b7344d45d9f7cf3106a5.zip
[LV, X86] Be more optimistic about vectorizing shifts.
Shifts with a uniform but non-constant count were considered very expensive to vectorize, because the splat of the uniform count and the shift would tend to appear in different blocks. That made the splat invisible to ISel, and we'd scalarize the shift at codegen time. Since r201655, CodeGenPrepare sinks those splats to be next to their use, and we are able to select the appropriate vector shifts. This updates the cost model to to take this into account by making shifts by a uniform cheap again. Differential Revision: https://reviews.llvm.org/D23049 llvm-svn: 277782
Diffstat (limited to 'llvm/lib/Analysis/CostModel.cpp')
-rw-r--r--llvm/lib/Analysis/CostModel.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/CostModel.cpp b/llvm/lib/Analysis/CostModel.cpp
index 68a4bea96ba..5dd54cd4d19 100644
--- a/llvm/lib/Analysis/CostModel.cpp
+++ b/llvm/lib/Analysis/CostModel.cpp
@@ -20,6 +20,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/Analysis/VectorUtils.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
@@ -123,7 +124,7 @@ static bool isAlternateVectorMask(SmallVectorImpl<int> &Mask) {
static TargetTransformInfo::OperandValueKind getOperandInfo(Value *V) {
TargetTransformInfo::OperandValueKind OpInfo =
- TargetTransformInfo::OK_AnyValue;
+ TargetTransformInfo::OK_AnyValue;
// Check for a splat of a constant or for a non uniform vector of constants.
if (isa<ConstantVector>(V) || isa<ConstantDataVector>(V)) {
@@ -132,6 +133,12 @@ static TargetTransformInfo::OperandValueKind getOperandInfo(Value *V) {
OpInfo = TargetTransformInfo::OK_UniformConstantValue;
}
+ // Check for a splat of a uniform value. This is not loop aware, so return
+ // true only for the obviously uniform cases (argument, globalvalue)
+ const Value *Splat = getSplatValue(V);
+ if (Splat && (isa<Argument>(Splat) || isa<GlobalValue>(Splat)))
+ OpInfo = TargetTransformInfo::OK_UniformValue;
+
return OpInfo;
}
OpenPOWER on IntegriCloud