1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer,instcombine -S -mtriple=x86_64-- -mcpu=corei7 < %s | FileCheck %s
4 define void @test1(float %a, float %b, float %c, float %d, ptr nocapture %p) {
7 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x float> poison, float [[A:%.*]], i64 0
8 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> [[TMP0]], float [[B:%.*]], i64 1
9 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x float> [[TMP1]], float [[C:%.*]], i64 2
10 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x float> [[TMP2]], float [[D:%.*]], i64 3
11 ; CHECK-NEXT: [[TMP4:%.*]] = fptosi <4 x float> [[TMP3]] to <4 x i32>
12 ; CHECK-NEXT: store <4 x i32> [[TMP4]], ptr [[P:%.*]], align 4, !tbaa [[TBAA0:![0-9]+]]
13 ; CHECK-NEXT: ret void
16 %conv = fptosi float %a to i32
17 %conv1 = fptosi float %b to i32
18 %conv3 = fptosi float %c to i32
19 %conv5 = fptosi float %d to i32
20 %incdec.ptr = getelementptr inbounds i32, ptr %p, i64 1
21 store i32 %conv, ptr %p, align 4, !tbaa !2
22 %incdec.ptr8 = getelementptr inbounds i32, ptr %p, i64 2
23 store i32 %conv1, ptr %incdec.ptr, align 4, !tbaa !2
24 %incdec.ptr10 = getelementptr inbounds i32, ptr %p, i64 3
25 store i32 %conv3, ptr %incdec.ptr8, align 4, !tbaa !2
26 store i32 %conv5, ptr %incdec.ptr10, align 4, !tbaa !2
30 define void @test1_vec(float %a, float %b, float %c, float %d, ptr nocapture %p) {
31 ; CHECK-LABEL: @test1_vec(
33 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x float> poison, float [[A:%.*]], i64 0
34 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> [[TMP0]], float [[B:%.*]], i64 1
35 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x float> [[TMP1]], float [[C:%.*]], i64 2
36 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x float> [[TMP2]], float [[D:%.*]], i64 3
37 ; CHECK-NEXT: [[TMP4:%.*]] = fptosi <4 x float> [[TMP3]] to <4 x i32>
38 ; CHECK-NEXT: store <4 x i32> [[TMP4]], ptr [[P:%.*]], align 16, !tbaa [[TBAA0]]
39 ; CHECK-NEXT: ret void
42 %conv = fptosi float %a to i32
43 %vecinit = insertelement <4 x i32> undef, i32 %conv, i32 0
44 %conv1 = fptosi float %b to i32
45 %vecinit2 = insertelement <4 x i32> %vecinit, i32 %conv1, i32 1
46 %conv3 = fptosi float %c to i32
47 %vecinit4 = insertelement <4 x i32> %vecinit2, i32 %conv3, i32 2
48 %conv5 = fptosi float %d to i32
49 %vecinit6 = insertelement <4 x i32> %vecinit4, i32 %conv5, i32 3
50 store <4 x i32> %vecinit6, ptr %p, align 16, !tbaa !2
54 define void @test2(i32 %a, i32 %b, i32 %c, i32 %d, ptr nocapture %p) {
55 ; CHECK-LABEL: @test2(
57 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i32> poison, i32 [[A:%.*]], i64 0
58 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> [[TMP0]], i32 [[B:%.*]], i64 1
59 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i32> [[TMP1]], i32 [[C:%.*]], i64 2
60 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i32> [[TMP2]], i32 [[D:%.*]], i64 3
61 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], <i32 1, i32 1, i32 1, i32 1>
62 ; CHECK-NEXT: store <4 x i32> [[TMP4]], ptr [[P:%.*]], align 4, !tbaa [[TBAA0]]
63 ; CHECK-NEXT: ret void
66 %add = add nsw i32 %a, 1
67 %add1 = add nsw i32 %b, 1
68 %add3 = add nsw i32 %c, 1
69 %add5 = add nsw i32 %d, 1
70 %incdec.ptr = getelementptr inbounds i32, ptr %p, i64 1
71 store i32 %add, ptr %p, align 4, !tbaa !2
72 %incdec.ptr8 = getelementptr inbounds i32, ptr %p, i64 2
73 store i32 %add1, ptr %incdec.ptr, align 4, !tbaa !2
74 %incdec.ptr10 = getelementptr inbounds i32, ptr %p, i64 3
75 store i32 %add3, ptr %incdec.ptr8, align 4, !tbaa !2
76 store i32 %add5, ptr %incdec.ptr10, align 4, !tbaa !2
80 define void @test2_vec(i32 %0, i32 %1, i32 %2, i32 %3, ptr nocapture %4) {
81 ; CHECK-LABEL: @test2_vec(
82 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x i32> poison, i32 [[TMP0:%.*]], i64 0
83 ; CHECK-NEXT: [[TMP7:%.*]] = insertelement <4 x i32> [[TMP6]], i32 [[TMP1:%.*]], i64 1
84 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <4 x i32> [[TMP7]], i32 [[TMP2:%.*]], i64 2
85 ; CHECK-NEXT: [[TMP9:%.*]] = insertelement <4 x i32> [[TMP8]], i32 [[TMP3:%.*]], i64 3
86 ; CHECK-NEXT: [[TMP10:%.*]] = add nsw <4 x i32> [[TMP9]], <i32 1, i32 1, i32 1, i32 1>
87 ; CHECK-NEXT: store <4 x i32> [[TMP10]], ptr [[TMP4:%.*]], align 16, !tbaa [[TBAA0]]
88 ; CHECK-NEXT: ret void
90 %6 = add nsw i32 %0, 1
91 %7 = insertelement <4 x i32> undef, i32 %6, i32 0
92 %8 = add nsw i32 %1, 1
93 %9 = insertelement <4 x i32> %7, i32 %8, i32 1
94 %10 = add nsw i32 %2, 1
95 %11 = insertelement <4 x i32> %9, i32 %10, i32 2
96 %12 = add nsw i32 %3, 1
97 %13 = insertelement <4 x i32> %11, i32 %12, i32 3
98 store <4 x i32> %13, ptr %4, align 16, !tbaa !2
102 !2 = !{!3, !3, i64 0}
103 !3 = !{!"int", !4, i64 0}
104 !4 = !{!"omnipotent char", !5, i64 0}
105 !5 = !{!"Simple C++ TBAA"}