[SLP] Vectorize for all-constant entries.
authorMichael Zolotukhin <mzolotukhin@apple.com>
Fri, 19 Jun 2015 17:40:15 +0000 (17:40 +0000)
committerMichael Zolotukhin <mzolotukhin@apple.com>
Fri, 19 Jun 2015 17:40:15 +0000 (17:40 +0000)
Differential Revision: http://reviews.llvm.org/D10531

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240144 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/X86/tiny-tree.ll

index 149936b11b30a4abed124047a8a7ca40419cb5af..370e2956ac4fe8a36176b12059b5e8afd0f01b60 100644 (file)
@@ -1637,8 +1637,10 @@ bool BoUpSLP::isFullyVectorizableTinyTree() {
   if (VectorizableTree.size() != 2)
     return false;
 
   if (VectorizableTree.size() != 2)
     return false;
 
-  // Handle splat stores.
-  if (!VectorizableTree[0].NeedToGather && isSplat(VectorizableTree[1].Scalars))
+  // Handle splat and all-constants stores.
+  if (!VectorizableTree[0].NeedToGather &&
+      (allConstant(VectorizableTree[1].Scalars) ||
+       isSplat(VectorizableTree[1].Scalars)))
     return true;
 
   // Gathering cost would be too much for tiny trees.
     return true;
 
   // Gathering cost would be too much for tiny trees.
index 6c93222ef93a782045ad05e61e3e41bd212ced9d..26af8165bc372e69be6c78a82ba7958407288d3c 100644 (file)
@@ -153,3 +153,19 @@ define void @store_splat(float*, float) {
   store float %1, float* %6, align 4
   ret void
 }
   store float %1, float* %6, align 4
   ret void
 }
+
+
+; CHECK-LABEL: store_const
+; CHECK: store <4 x i32>
+define void @store_const(i32* %a) {
+entry:
+  %ptr0 = getelementptr inbounds i32, i32* %a, i64 0
+  store i32 10, i32* %ptr0, align 4
+  %ptr1 = getelementptr inbounds i32, i32* %a, i64 1
+  store i32 30, i32* %ptr1, align 4
+  %ptr2 = getelementptr inbounds i32, i32* %a, i64 2
+  store i32 20, i32* %ptr2, align 4
+  %ptr3 = getelementptr inbounds i32, i32* %a, i64 3
+  store i32 40, i32* %ptr3, align 4
+  ret void
+}