Add support for bottom-up SLP vectorization infrastructure.
[oota-llvm.git] / test / Transforms / SLPVectorizer / X86 / saxpy.ll
1 ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
2
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.8.0"
5
6 ; SLP vectorization example from http://cs.stanford.edu/people/eschkufz/research/asplos291-schkufza.pdf
7 ;CHECK: SAXPY
8 ;CHECK: mul <4 x i32>
9 ;CHECK: ret
10
11 define void @SAXPY(i32* noalias nocapture %x, i32* noalias nocapture %y, i32 %a, i64 %i) #0 {
12   %1 = getelementptr inbounds i32* %x, i64 %i
13   %2 = load i32* %1, align 4, !tbaa !0
14   %3 = mul nsw i32 %2, %a
15   %4 = getelementptr inbounds i32* %y, i64 %i
16   %5 = load i32* %4, align 4, !tbaa !0
17   %6 = add nsw i32 %3, %5
18   store i32 %6, i32* %1, align 4, !tbaa !0
19   %7 = add i64 %i, 1
20   %8 = getelementptr inbounds i32* %x, i64 %7
21   %9 = load i32* %8, align 4, !tbaa !0
22   %10 = mul nsw i32 %9, %a
23   %11 = getelementptr inbounds i32* %y, i64 %7
24   %12 = load i32* %11, align 4, !tbaa !0
25   %13 = add nsw i32 %10, %12
26   store i32 %13, i32* %8, align 4, !tbaa !0
27   %14 = add i64 %i, 2
28   %15 = getelementptr inbounds i32* %x, i64 %14
29   %16 = load i32* %15, align 4, !tbaa !0
30   %17 = mul nsw i32 %16, %a
31   %18 = getelementptr inbounds i32* %y, i64 %14
32   %19 = load i32* %18, align 4, !tbaa !0
33   %20 = add nsw i32 %17, %19
34   store i32 %20, i32* %15, align 4, !tbaa !0
35   %21 = add i64 %i, 3
36   %22 = getelementptr inbounds i32* %x, i64 %21
37   %23 = load i32* %22, align 4, !tbaa !0
38   %24 = mul nsw i32 %23, %a
39   %25 = getelementptr inbounds i32* %y, i64 %21
40   %26 = load i32* %25, align 4, !tbaa !0
41   %27 = add nsw i32 %24, %26
42   store i32 %27, i32* %22, align 4, !tbaa !0
43   ret void
44 }
45
46 attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
47
48 !0 = metadata !{metadata !"int", metadata !1}
49 !1 = metadata !{metadata !"omnipotent char", metadata !2}
50 !2 = metadata !{metadata !"Simple C/C++ TBAA"}