[PATCH] [SLP] Vectorize all-constant entries.
Michael Zolotukhin
mzolotukhin at apple.com
Thu Jun 18 17:27:33 PDT 2015
Hi nadav, aschwaighofer,
Currently SLP gives up when a tree contains a set of constants, and that can be easily fixed.
http://reviews.llvm.org/D10558
Files:
lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/X86/tiny-tree.ll
Index: lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1637,8 +1637,10 @@
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.
Index: test/Transforms/SLPVectorizer/X86/tiny-tree.ll
===================================================================
--- test/Transforms/SLPVectorizer/X86/tiny-tree.ll
+++ test/Transforms/SLPVectorizer/X86/tiny-tree.ll
@@ -153,3 +153,19 @@
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
+}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10558.27980.patch
Type: text/x-patch
Size: 1445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150619/fc6da85a/attachment.bin>
More information about the llvm-commits
mailing list