1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
4 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"
5 target triple = "x86_64-apple-macosx10.8.0"
7 ; SLP vectorization example from http://cs.stanford.edu/people/eschkufz/research/asplos291-schkufza.pdf
8 define void @SAXPY(i32* noalias nocapture %x, i32* noalias nocapture %y, i32 %a, i64 %i) {
10 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[X:%.*]], i64 [[I:%.*]]
11 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, i32* [[Y:%.*]], i64 [[I]]
12 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32* [[TMP1]] to <4 x i32>*
13 ; CHECK-NEXT: [[TMP4:%.*]] = load <4 x i32>, <4 x i32>* [[TMP3]], align 4
14 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x i32> undef, i32 [[A:%.*]], i32 0
15 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x i32> [[TMP5]], i32 [[A]], i32 1
16 ; CHECK-NEXT: [[TMP7:%.*]] = insertelement <4 x i32> [[TMP6]], i32 [[A]], i32 2
17 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <4 x i32> [[TMP7]], i32 [[A]], i32 3
18 ; CHECK-NEXT: [[TMP9:%.*]] = mul nsw <4 x i32> [[TMP4]], [[TMP8]]
19 ; CHECK-NEXT: [[TMP10:%.*]] = bitcast i32* [[TMP2]] to <4 x i32>*
20 ; CHECK-NEXT: [[TMP11:%.*]] = load <4 x i32>, <4 x i32>* [[TMP10]], align 4
21 ; CHECK-NEXT: [[TMP12:%.*]] = add nsw <4 x i32> [[TMP9]], [[TMP11]]
22 ; CHECK-NEXT: [[TMP13:%.*]] = bitcast i32* [[TMP1]] to <4 x i32>*
23 ; CHECK-NEXT: store <4 x i32> [[TMP12]], <4 x i32>* [[TMP13]], align 4
24 ; CHECK-NEXT: ret void
26 %1 = getelementptr inbounds i32, i32* %x, i64 %i
27 %2 = load i32, i32* %1, align 4
28 %3 = mul nsw i32 %2, %a
29 %4 = getelementptr inbounds i32, i32* %y, i64 %i
30 %5 = load i32, i32* %4, align 4
31 %6 = add nsw i32 %3, %5
32 store i32 %6, i32* %1, align 4
34 %8 = getelementptr inbounds i32, i32* %x, i64 %7
35 %9 = load i32, i32* %8, align 4
36 %10 = mul nsw i32 %9, %a
37 %11 = getelementptr inbounds i32, i32* %y, i64 %7
38 %12 = load i32, i32* %11, align 4
39 %13 = add nsw i32 %10, %12
40 store i32 %13, i32* %8, align 4
42 %15 = getelementptr inbounds i32, i32* %x, i64 %14
43 %16 = load i32, i32* %15, align 4
44 %17 = mul nsw i32 %16, %a
45 %18 = getelementptr inbounds i32, i32* %y, i64 %14
46 %19 = load i32, i32* %18, align 4
47 %20 = add nsw i32 %17, %19
48 store i32 %20, i32* %15, align 4
50 %22 = getelementptr inbounds i32, i32* %x, i64 %21
51 %23 = load i32, i32* %22, align 4
52 %24 = mul nsw i32 %23, %a
53 %25 = getelementptr inbounds i32, i32* %y, i64 %21
54 %26 = load i32, i32* %25, align 4
55 %27 = add nsw i32 %24, %26
56 store i32 %27, i32* %22, align 4
60 ; Make sure we don't crash on this one.
61 define void @SAXPY_crash(i32* noalias nocapture %x, i32* noalias nocapture %y, i64 %i) {
62 ; CHECK-LABEL: @SAXPY_crash(
63 ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[I:%.*]], 1
64 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, i32* [[X:%.*]], i64 [[TMP1]]
65 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, i32* [[Y:%.*]], i64 [[TMP1]]
66 ; CHECK-NEXT: [[TMP4:%.*]] = load i32, i32* [[TMP3]], align 4
67 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw i32 undef, [[TMP4]]
68 ; CHECK-NEXT: store i32 [[TMP5]], i32* [[TMP2]], align 4
69 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[I]], 2
70 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[TMP6]]
71 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32, i32* [[Y]], i64 [[TMP6]]
72 ; CHECK-NEXT: [[TMP9:%.*]] = load i32, i32* [[TMP8]], align 4
73 ; CHECK-NEXT: [[TMP10:%.*]] = add nsw i32 undef, [[TMP9]]
74 ; CHECK-NEXT: store i32 [[TMP10]], i32* [[TMP7]], align 4
75 ; CHECK-NEXT: ret void
78 %2 = getelementptr inbounds i32, i32* %x, i64 %1
79 %3 = getelementptr inbounds i32, i32* %y, i64 %1
80 %4 = load i32, i32* %3, align 4
81 %5 = add nsw i32 undef, %4
82 store i32 %5, i32* %2, align 4
84 %7 = getelementptr inbounds i32, i32* %x, i64 %6
85 %8 = getelementptr inbounds i32, i32* %y, i64 %6
86 %9 = load i32, i32* %8, align 4
87 %10 = add nsw i32 undef, %9
88 store i32 %10, i32* %7, align 4