1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -mtriple=x86_64-unknown -mattr=+avx -slp-vectorizer | FileCheck %s
6 define i32 @jumbled-load(i32* noalias nocapture %in, i32* noalias nocapture %inn, i32* noalias nocapture %out) {
7 ; CHECK-LABEL: @jumbled-load(
8 ; CHECK-NEXT: [[IN_ADDR:%.*]] = getelementptr inbounds i32, i32* [[IN:%.*]], i64 0
9 ; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i32, i32* [[IN_ADDR]], i64 3
10 ; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i32, i32* [[IN_ADDR]], i64 1
11 ; CHECK-NEXT: [[GEP_3:%.*]] = getelementptr inbounds i32, i32* [[IN_ADDR]], i64 2
12 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[IN_ADDR]] to <4 x i32>*
13 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]], align 4
14 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP2]], <4 x i32> poison, <4 x i32> <i32 1, i32 3, i32 2, i32 0>
15 ; CHECK-NEXT: [[INN_ADDR:%.*]] = getelementptr inbounds i32, i32* [[INN:%.*]], i64 0
16 ; CHECK-NEXT: [[GEP_4:%.*]] = getelementptr inbounds i32, i32* [[INN_ADDR]], i64 2
17 ; CHECK-NEXT: [[GEP_5:%.*]] = getelementptr inbounds i32, i32* [[INN_ADDR]], i64 3
18 ; CHECK-NEXT: [[GEP_6:%.*]] = getelementptr inbounds i32, i32* [[INN_ADDR]], i64 1
19 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32* [[INN_ADDR]] to <4 x i32>*
20 ; CHECK-NEXT: [[TMP4:%.*]] = load <4 x i32>, <4 x i32>* [[TMP3]], align 4
21 ; CHECK-NEXT: [[SHUFFLE1:%.*]] = shufflevector <4 x i32> [[TMP4]], <4 x i32> poison, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
22 ; CHECK-NEXT: [[TMP5:%.*]] = mul <4 x i32> [[SHUFFLE]], [[SHUFFLE1]]
23 ; CHECK-NEXT: [[GEP_7:%.*]] = getelementptr inbounds i32, i32* [[OUT:%.*]], i64 0
24 ; CHECK-NEXT: [[GEP_8:%.*]] = getelementptr inbounds i32, i32* [[OUT]], i64 1
25 ; CHECK-NEXT: [[GEP_9:%.*]] = getelementptr inbounds i32, i32* [[OUT]], i64 2
26 ; CHECK-NEXT: [[GEP_10:%.*]] = getelementptr inbounds i32, i32* [[OUT]], i64 3
27 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast i32* [[GEP_7]] to <4 x i32>*
28 ; CHECK-NEXT: store <4 x i32> [[TMP5]], <4 x i32>* [[TMP6]], align 4
29 ; CHECK-NEXT: ret i32 undef
31 %in.addr = getelementptr inbounds i32, i32* %in, i64 0
32 %load.1 = load i32, i32* %in.addr, align 4
33 %gep.1 = getelementptr inbounds i32, i32* %in.addr, i64 3
34 %load.2 = load i32, i32* %gep.1, align 4
35 %gep.2 = getelementptr inbounds i32, i32* %in.addr, i64 1
36 %load.3 = load i32, i32* %gep.2, align 4
37 %gep.3 = getelementptr inbounds i32, i32* %in.addr, i64 2
38 %load.4 = load i32, i32* %gep.3, align 4
39 %inn.addr = getelementptr inbounds i32, i32* %inn, i64 0
40 %load.5 = load i32, i32* %inn.addr, align 4
41 %gep.4 = getelementptr inbounds i32, i32* %inn.addr, i64 2
42 %load.6 = load i32, i32* %gep.4, align 4
43 %gep.5 = getelementptr inbounds i32, i32* %inn.addr, i64 3
44 %load.7 = load i32, i32* %gep.5, align 4
45 %gep.6 = getelementptr inbounds i32, i32* %inn.addr, i64 1
46 %load.8 = load i32, i32* %gep.6, align 4
47 %mul.1 = mul i32 %load.3, %load.5
48 %mul.2 = mul i32 %load.2, %load.8
49 %mul.3 = mul i32 %load.4, %load.7
50 %mul.4 = mul i32 %load.1, %load.6
51 %gep.7 = getelementptr inbounds i32, i32* %out, i64 0
52 store i32 %mul.1, i32* %gep.7, align 4
53 %gep.8 = getelementptr inbounds i32, i32* %out, i64 1
54 store i32 %mul.2, i32* %gep.8, align 4
55 %gep.9 = getelementptr inbounds i32, i32* %out, i64 2
56 store i32 %mul.3, i32* %gep.9, align 4
57 %gep.10 = getelementptr inbounds i32, i32* %out, i64 3
58 store i32 %mul.4, i32* %gep.10, align 4
64 define i32 @jumbled-load-multiuses(i32* noalias nocapture %in, i32* noalias nocapture %out) {
65 ; CHECK-LABEL: @jumbled-load-multiuses(
66 ; CHECK-NEXT: [[IN_ADDR:%.*]] = getelementptr inbounds i32, i32* [[IN:%.*]], i64 0
67 ; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr inbounds i32, i32* [[IN_ADDR]], i64 3
68 ; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i32, i32* [[IN_ADDR]], i64 1
69 ; CHECK-NEXT: [[GEP_3:%.*]] = getelementptr inbounds i32, i32* [[IN_ADDR]], i64 2
70 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[IN_ADDR]] to <4 x i32>*
71 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i32>, <4 x i32>* [[TMP1]], align 4
72 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP2]], <4 x i32> poison, <4 x i32> <i32 1, i32 3, i32 2, i32 0>
73 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[SHUFFLE]], i32 2
74 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x i32> poison, i32 [[TMP3]], i32 0
75 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x i32> [[SHUFFLE]], i32 1
76 ; CHECK-NEXT: [[TMP6:%.*]] = insertelement <4 x i32> [[TMP4]], i32 [[TMP5]], i32 1
77 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i32> [[SHUFFLE]], i32 3
78 ; CHECK-NEXT: [[TMP8:%.*]] = insertelement <4 x i32> [[TMP6]], i32 [[TMP7]], i32 2
79 ; CHECK-NEXT: [[TMP9:%.*]] = extractelement <4 x i32> [[SHUFFLE]], i32 0
80 ; CHECK-NEXT: [[TMP10:%.*]] = insertelement <4 x i32> [[TMP8]], i32 [[TMP9]], i32 3
81 ; CHECK-NEXT: [[TMP11:%.*]] = mul <4 x i32> [[SHUFFLE]], [[TMP10]]
82 ; CHECK-NEXT: [[GEP_7:%.*]] = getelementptr inbounds i32, i32* [[OUT:%.*]], i64 0
83 ; CHECK-NEXT: [[GEP_8:%.*]] = getelementptr inbounds i32, i32* [[OUT]], i64 1
84 ; CHECK-NEXT: [[GEP_9:%.*]] = getelementptr inbounds i32, i32* [[OUT]], i64 2
85 ; CHECK-NEXT: [[GEP_10:%.*]] = getelementptr inbounds i32, i32* [[OUT]], i64 3
86 ; CHECK-NEXT: [[TMP12:%.*]] = bitcast i32* [[GEP_7]] to <4 x i32>*
87 ; CHECK-NEXT: store <4 x i32> [[TMP11]], <4 x i32>* [[TMP12]], align 4
88 ; CHECK-NEXT: ret i32 undef
90 %in.addr = getelementptr inbounds i32, i32* %in, i64 0
91 %load.1 = load i32, i32* %in.addr, align 4
92 %gep.1 = getelementptr inbounds i32, i32* %in.addr, i64 3
93 %load.2 = load i32, i32* %gep.1, align 4
94 %gep.2 = getelementptr inbounds i32, i32* %in.addr, i64 1
95 %load.3 = load i32, i32* %gep.2, align 4
96 %gep.3 = getelementptr inbounds i32, i32* %in.addr, i64 2
97 %load.4 = load i32, i32* %gep.3, align 4
98 %mul.1 = mul i32 %load.3, %load.4
99 %mul.2 = mul i32 %load.2, %load.2
100 %mul.3 = mul i32 %load.4, %load.1
101 %mul.4 = mul i32 %load.1, %load.3
102 %gep.7 = getelementptr inbounds i32, i32* %out, i64 0
103 store i32 %mul.1, i32* %gep.7, align 4
104 %gep.8 = getelementptr inbounds i32, i32* %out, i64 1
105 store i32 %mul.2, i32* %gep.8, align 4
106 %gep.9 = getelementptr inbounds i32, i32* %out, i64 2
107 store i32 %mul.3, i32* %gep.9, align 4
108 %gep.10 = getelementptr inbounds i32, i32* %out, i64 3
109 store i32 %mul.4, i32* %gep.10, align 4