summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-01-15 23:43:14 +0000
committerNadav Rotem <nrotem@apple.com>2013-01-15 23:43:14 +0000
commit83d585383345b84ae4a9590e97135f95ae39406b (patch)
treeede090ffa5262d09f5d33c13af870704eacf283e /lib/Transforms/InstCombine/InstCombineVectorOps.cpp
parent9ccb76998f741a7d3f0f217392a783dfb99c6e87 (diff)
downloadllvm-83d585383345b84ae4a9590e97135f95ae39406b.tar.gz
llvm-83d585383345b84ae4a9590e97135f95ae39406b.tar.bz2
llvm-83d585383345b84ae4a9590e97135f95ae39406b.tar.xz
Teach InstCombine to optimize extract of a value from a vector add operation with a constant zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineVectorOps.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineVectorOps.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index dd7ea14e8a..8bfcc805bc 100644
--- a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -13,7 +13,9 @@
//===----------------------------------------------------------------------===//
#include "InstCombine.h"
+#include "llvm/Support/PatternMatch.h"
using namespace llvm;
+using namespace PatternMatch;
/// CheapToScalarize - Return true if the value is cheaper to scalarize than it
/// is to leave as a vector operation. isConstant indicates whether we're
@@ -92,6 +94,13 @@ static Value *FindScalarElement(Value *V, unsigned EltNo) {
return FindScalarElement(SVI->getOperand(1), InEl - LHSWidth);
}
+ // Extract a value from a vector add operation with a constant zero.
+ Value *Val = 0; Constant *Con = 0;
+ if (match(V, m_Add(m_Value(Val), m_Constant(Con)))) {
+ if (Con->getAggregateElement(EltNo)->isNullValue())
+ return FindScalarElement(Val, EltNo);
+ }
+
// Otherwise, we don't know.
return 0;
}