[SLPVectorizer] Handle GEP with differing constant index types

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!

llvm-svn: 272206
This commit is contained in:
Michael Zolotukhin 2016-06-08 21:55:16 +00:00
parent c5d0edc533
commit 93a3ca7cde
2 changed files with 23 additions and 1 deletions

View 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!");

View File

@ -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
}