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