[PATCH] D20685: SLPVectorizer to handle GEP with differing constant index types

Jesper Antonsson via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 09:12:31 PDT 2016


JesperAntonsson created this revision.
JesperAntonsson added reviewers: mzolotukhin, nadav.
JesperAntonsson added a subscriber: llvm-commits.
Herald added a subscriber: mzolotukhin.

This is a solution to [[ https://llvm.org/bugs/show_bug.cgi?id=27617 | bug 27617 ]]. 

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.

http://reviews.llvm.org/D20685

Files:
  lib/Transforms/Vectorize/SLPVectorizer.cpp
  test/Transforms/SLPVectorizer/X86/gep_mismatch.ll

Index: test/Transforms/SLPVectorizer/X86/gep_mismatch.ll
===================================================================
--- /dev/null
+++ test/Transforms/SLPVectorizer/X86/gep_mismatch.ll
@@ -0,0 +1,39 @@
+; RUN: opt < %s -S -mcpu=x86-64 -mtriple=x86_64-linux -indvars -slp-vectorizer -O1
+
+; This code will result in GEPs with different index types, i8 and i64,
+; which should not matter for the SLPVectorizer.
+
+target datalayout = "E-B16-p:16:16-p20:32:16-p21:32:16-p40:32:16-F40-i1:16-i8:16-i32:16-i64:16-f32:16-f64:16-v32:16:16-v64:16:16-v128:16:16-a:0:16-i24:16-i40:16-n16:32"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @matmul([4 x float]* noalias %r.8.par, [4 x float]* %x.9.par, [4 x float]* %y.10.par) #3 {
+  %ls3.16 = alloca float*
+  %ls6.18 = alloca float*
+  %ls7.19 = alloca float*
+  br label %bb3
+
+bb3:
+  %_tmp22 = load float*, float** %ls7.19
+  store float* %_tmp22, float** %ls3.16
+  %_tmp23 = load float*, float** %ls3.16
+  %_tmp24 = load float, float* %_tmp23
+  %_tmp27 = fmul float %_tmp24, undef
+  %_tmp50 = load float*, float** %ls6.18
+  store float undef, float* %_tmp50
+  %_tmp55 = load float*, float** %ls6.18
+  %_tmp56 = getelementptr float, float* %_tmp55, i64 1
+  store float* %_tmp56, float** %ls6.18
+  br i1 undef, label %bb3, label %bb8
+
+bb8:
+  %_tmp61 = load float*, float** %ls7.19
+  %_tmp62 = getelementptr float, float* %_tmp61, i64 4
+  store float* %_tmp62, float** %ls7.19
+  %_tmp64 = icmp slt i16 undef, 4
+  br i1 %_tmp64, label %bb3, label %bb9
+
+bb9:
+  ret void
+}
+
+declare void @TEST__MAIN() #3
Index: lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1014,7 +1014,7 @@
 
 
 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!");
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20685.58622.patch
Type: text/x-patch
Size: 2080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160526/712a13a0/attachment.bin>


More information about the llvm-commits mailing list