summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
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
commit7df850924d07849d313a90d79ff52e1e5ae55c68 (patch)
treea5d51e9cfb943240e7b9dd00769f0b0e419537da /llvm/lib/Transforms
parentcaa7df49a96c05009e8a64058b6eb765ecc711b7 (diff)
downloadbcm5719-llvm-7df850924d07849d313a90d79ff52e1e5ae55c68.tar.gz
bcm5719-llvm-7df850924d07849d313a90d79ff52e1e5ae55c68.zip
Teach InstCombine to optimize extract of a value from a vector add operation with a constant zero.
llvm-svn: 172576
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index dd7ea14e8a8..8bfcc805bc8 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud