1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basic-aa -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> poison, i32 [[A:%.*]], i32 0
15 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP5]], <4 x i32> poison, <4 x i32> zeroinitializer
16 ; CHECK-NEXT: [[TMP6:%.*]] = mul nsw <4 x i32> [[TMP4]], [[SHUFFLE]]
17 ; CHECK-NEXT: [[TMP7:%.*]] = bitcast i32* [[TMP2]] to <4 x i32>*
18 ; CHECK-NEXT: [[TMP8:%.*]] = load <4 x i32>, <4 x i32>* [[TMP7]], align 4
19 ; CHECK-NEXT: [[TMP9:%.*]] = add nsw <4 x i32> [[TMP6]], [[TMP8]]
20 ; CHECK-NEXT: [[TMP10:%.*]] = bitcast i32* [[TMP1]] to <4 x i32>*
21 ; CHECK-NEXT: store <4 x i32> [[TMP9]], <4 x i32>* [[TMP10]], align 4
22 ; CHECK-NEXT: ret void
24 %1 = getelementptr inbounds i32, i32* %x, i64 %i
25 %2 = load i32, i32* %1, align 4
26 %3 = mul nsw i32 %2, %a
27 %4 = getelementptr inbounds i32, i32* %y, i64 %i
28 %5 = load i32, i32* %4, align 4
29 %6 = add nsw i32 %3, %5
30 store i32 %6, i32* %1, align 4
32 %8 = getelementptr inbounds i32, i32* %x, i64 %7
33 %9 = load i32, i32* %8, align 4
34 %10 = mul nsw i32 %9, %a
35 %11 = getelementptr inbounds i32, i32* %y, i64 %7
36 %12 = load i32, i32* %11, align 4
37 %13 = add nsw i32 %10, %12
38 store i32 %13, i32* %8, align 4
40 %15 = getelementptr inbounds i32, i32* %x, i64 %14
41 %16 = load i32, i32* %15, align 4
42 %17 = mul nsw i32 %16, %a
43 %18 = getelementptr inbounds i32, i32* %y, i64 %14
44 %19 = load i32, i32* %18, align 4
45 %20 = add nsw i32 %17, %19
46 store i32 %20, i32* %15, align 4
48 %22 = getelementptr inbounds i32, i32* %x, i64 %21
49 %23 = load i32, i32* %22, align 4
50 %24 = mul nsw i32 %23, %a
51 %25 = getelementptr inbounds i32, i32* %y, i64 %21
52 %26 = load i32, i32* %25, align 4
53 %27 = add nsw i32 %24, %26
54 store i32 %27, i32* %22, align 4
58 ; Make sure we don't crash on this one.
59 define void @SAXPY_crash(i32* noalias nocapture %x, i32* noalias nocapture %y, i64 %i) {
60 ; CHECK-LABEL: @SAXPY_crash(
61 ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[I:%.*]], 1
62 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, i32* [[X:%.*]], i64 [[TMP1]]
63 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, i32* [[Y:%.*]], i64 [[TMP1]]
64 ; CHECK-NEXT: [[TMP4:%.*]] = load i32, i32* [[TMP3]], align 4
65 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw i32 undef, [[TMP4]]
66 ; CHECK-NEXT: store i32 [[TMP5]], i32* [[TMP2]], align 4
67 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[I]], 2
68 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 [[TMP6]]
69 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32, i32* [[Y]], i64 [[TMP6]]
70 ; CHECK-NEXT: [[TMP9:%.*]] = load i32, i32* [[TMP8]], align 4
71 ; CHECK-NEXT: [[TMP10:%.*]] = add nsw i32 undef, [[TMP9]]
72 ; CHECK-NEXT: store i32 [[TMP10]], i32* [[TMP7]], align 4
73 ; CHECK-NEXT: ret void
76 %2 = getelementptr inbounds i32, i32* %x, i64 %1
77 %3 = getelementptr inbounds i32, i32* %y, i64 %1
78 %4 = load i32, i32* %3, align 4
79 %5 = add nsw i32 undef, %4
80 store i32 %5, i32* %2, align 4
82 %7 = getelementptr inbounds i32, i32* %x, i64 %6
83 %8 = getelementptr inbounds i32, i32* %y, i64 %6
84 %9 = load i32, i32* %8, align 4
85 %10 = add nsw i32 undef, %9
86 store i32 %10, i32* %7, align 4