Home | History | Annotate | Download | only in X86
      1 ; RUN: opt < %s -basicaa -slp-vectorizer -S |FileCheck %s
      2 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=slp-vectorizer -S |FileCheck %s
      3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
      4 target triple = "x86_64-unknown-unknown"
      5 
      6 ; Test if SLP can handle GEP expressions.
      7 ; The test perform the following action:
      8 ;   x->first  = y->first  + 16
      9 ;   x->second = y->second + 16
     10 
     11 ; CHECK-LABEL: foo1
     12 ; CHECK: <2 x i32*>
     13 define void @foo1 ({ i32*, i32* }* noalias %x, { i32*, i32* }* noalias %y) {
     14   %1 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 0
     15   %2 = load i32*, i32** %1, align 8
     16   %3 = getelementptr inbounds i32, i32* %2, i64 16
     17   %4 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 0
     18   store i32* %3, i32** %4, align 8
     19   %5 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 1
     20   %6 = load i32*, i32** %5, align 8
     21   %7 = getelementptr inbounds i32, i32* %6, i64 16
     22   %8 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 1
     23   store i32* %7, i32** %8, align 8
     24   ret void
     25 }
     26 
     27 ; Test that we don't vectorize GEP expressions if indexes are not constants.
     28 ; We can't produce an efficient code in that case.
     29 ; CHECK-LABEL: foo2
     30 ; CHECK-NOT: <2 x i32*>
     31 define void @foo2 ({ i32*, i32* }* noalias %x, { i32*, i32* }* noalias %y, i32 %i) {
     32   %1 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 0
     33   %2 = load i32*, i32** %1, align 8
     34   %3 = getelementptr inbounds i32, i32* %2, i32 %i
     35   %4 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 0
     36   store i32* %3, i32** %4, align 8
     37   %5 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %y, i64 0, i32 1
     38   %6 = load i32*, i32** %5, align 8
     39   %7 = getelementptr inbounds i32, i32* %6, i32 %i
     40   %8 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %x, i64 0, i32 1
     41   store i32* %7, i32** %8, align 8
     42   ret void
     43 }
     44