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