OSDN Git Service

[SLPVectorizer] Handle GEP with differing constant index types
authorMichael Zolotukhin <mzolotukhin@apple.com>
Wed, 8 Jun 2016 21:55:16 +0000 (21:55 +0000)
committerMichael Zolotukhin <mzolotukhin@apple.com>
Wed, 8 Jun 2016 21:55:16 +0000 (21:55 +0000)
Summary:
This fixes PR27617.

Bug description: The SLPVectorizer asserts on encountering GEPs with different index types, such as i8 and i64.

The patch includes a simple relaxation of the assert to allow constants being of different types, along with a regression test that will provoke the unrelaxed assert.

Reviewers: nadav, mzolotukhin

Subscribers: JesperAntonsson, llvm-commits, mzolotukhin

Differential Revision: http://reviews.llvm.org/D20685

Patch by Jesper Antonsson!

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

lib/Transforms/Vectorize/SLPVectorizer.cpp
test/Transforms/SLPVectorizer/X86/gep_mismatch.ll [new file with mode: 0644]

index 5782443..66d7fc8 100644 (file)
@@ -1014,7 +1014,7 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
 
 
 void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth) {
-  bool SameTy = getSameType(VL); (void)SameTy;
+  bool SameTy = allConstant(VL) || getSameType(VL); (void)SameTy;
   bool isAltShuffle = false;
   assert(SameTy && "Invalid types!");
 
diff --git a/test/Transforms/SLPVectorizer/X86/gep_mismatch.ll b/test/Transforms/SLPVectorizer/X86/gep_mismatch.ll
new file mode 100644 (file)
index 0000000..1cd28a9
--- /dev/null
@@ -0,0 +1,22 @@
+; RUN: opt < %s -S -slp-vectorizer
+
+; This code has GEPs with different index types, which should not
+; matter for the SLPVectorizer.
+
+target triple = "x86_64--linux"
+
+define void @foo() {
+entry:
+  br label %bb1
+
+bb1:
+  %ls1.ph = phi float* [ %_tmp1, %bb1 ], [ undef, %entry ]
+  %ls2.ph = phi float* [ %_tmp2, %bb1 ], [ undef, %entry ]
+  store float undef, float* %ls1.ph
+  %_tmp1 = getelementptr float, float* %ls1.ph, i32 1
+  %_tmp2 = getelementptr float, float* %ls2.ph, i64 4
+  br i1 false, label %bb1, label %bb2
+
+bb2:
+  ret void
+}