1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer -S -o - -mtriple=i386 -mcpu=haswell < %s | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
5 @shift = common local_unnamed_addr global [10 x i32] zeroinitializer, align 4
6 @data = common local_unnamed_addr global [10 x ptr] zeroinitializer, align 4
8 define void @flat(i32 %intensity) {
11 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @shift, align 4
12 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr getelementptr inbounds ([10 x i32], ptr @shift, i32 0, i32 1), align 4
13 ; CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr @data, align 4
14 ; CHECK-NEXT: [[TMP3:%.*]] = load ptr, ptr getelementptr inbounds ([10 x ptr], ptr @data, i32 0, i32 1), align 4
15 ; CHECK-NEXT: [[SHR:%.*]] = lshr i32 1, [[TMP0]]
16 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[TMP2]], i32 [[SHR]]
17 ; CHECK-NEXT: [[SHR1:%.*]] = lshr i32 1, [[TMP1]]
18 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i8, ptr [[TMP3]], i32 [[SHR1]]
19 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
20 ; CHECK: for.cond.cleanup:
21 ; CHECK-NEXT: ret void
23 ; CHECK-NEXT: [[D1_DATA_046:%.*]] = phi ptr [ [[TMP3]], [[ENTRY:%.*]] ], [ [[ADD_PTR23_1:%.*]], [[FOR_BODY]] ]
24 ; CHECK-NEXT: [[Y_045:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[INC_1:%.*]], [[FOR_BODY]] ]
25 ; CHECK-NEXT: [[TMP4:%.*]] = load i8, ptr [[ARRAYIDX]], align 1
26 ; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[TMP4]] to i32
27 ; CHECK-NEXT: [[SUB:%.*]] = add nsw i32 [[CONV]], -128
28 ; CHECK-NEXT: [[TMP5:%.*]] = load i8, ptr [[ARRAYIDX2]], align 1
29 ; CHECK-NEXT: [[CONV3:%.*]] = zext i8 [[TMP5]] to i32
30 ; CHECK-NEXT: [[SUB4:%.*]] = add nsw i32 [[CONV3]], -128
31 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[SUB]], -1
32 ; CHECK-NEXT: [[SUB7:%.*]] = sub nsw i32 128, [[CONV]]
33 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP5]], i32 [[SUB]], i32 [[SUB7]]
34 ; CHECK-NEXT: [[CMP8:%.*]] = icmp sgt i32 [[SUB4]], -1
35 ; CHECK-NEXT: [[SUB12:%.*]] = sub nsw i32 128, [[CONV3]]
36 ; CHECK-NEXT: [[COND14:%.*]] = select i1 [[CMP8]], i32 [[SUB4]], i32 [[SUB12]]
37 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[COND14]], [[COND]]
38 ; CHECK-NEXT: [[IDX_NEG:%.*]] = sub nsw i32 0, [[ADD]]
39 ; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[D1_DATA_046]], i32 [[IDX_NEG]]
40 ; CHECK-NEXT: [[TMP6:%.*]] = load i8, ptr [[ADD_PTR]], align 1
41 ; CHECK-NEXT: [[CONV15:%.*]] = zext i8 [[TMP6]] to i32
42 ; CHECK-NEXT: [[ADD16:%.*]] = add nsw i32 [[CONV15]], [[INTENSITY:%.*]]
43 ; CHECK-NEXT: [[CONV17:%.*]] = trunc i32 [[ADD16]] to i8
44 ; CHECK-NEXT: store i8 [[CONV17]], ptr [[ADD_PTR]], align 1
45 ; CHECK-NEXT: [[ADD_PTR18:%.*]] = getelementptr inbounds i8, ptr [[D1_DATA_046]], i32 [[ADD]]
46 ; CHECK-NEXT: [[TMP7:%.*]] = load i8, ptr [[ADD_PTR18]], align 1
47 ; CHECK-NEXT: [[NOT_TOBOOL:%.*]] = icmp eq i8 [[TMP7]], 0
48 ; CHECK-NEXT: [[CONV21:%.*]] = zext i1 [[NOT_TOBOOL]] to i8
49 ; CHECK-NEXT: store i8 [[CONV21]], ptr [[ADD_PTR18]], align 1
50 ; CHECK-NEXT: [[ADD_PTR23:%.*]] = getelementptr inbounds i8, ptr [[D1_DATA_046]], i32 [[TMP1]]
51 ; CHECK-NEXT: [[TMP8:%.*]] = load i8, ptr [[ARRAYIDX]], align 1
52 ; CHECK-NEXT: [[CONV_1:%.*]] = zext i8 [[TMP8]] to i32
53 ; CHECK-NEXT: [[SUB_1:%.*]] = add nsw i32 [[CONV_1]], -128
54 ; CHECK-NEXT: [[TMP9:%.*]] = load i8, ptr [[ARRAYIDX2]], align 1
55 ; CHECK-NEXT: [[CONV3_1:%.*]] = zext i8 [[TMP9]] to i32
56 ; CHECK-NEXT: [[SUB4_1:%.*]] = add nsw i32 [[CONV3_1]], -128
57 ; CHECK-NEXT: [[CMP5_1:%.*]] = icmp sgt i32 [[SUB_1]], -1
58 ; CHECK-NEXT: [[SUB7_1:%.*]] = sub nsw i32 128, [[CONV_1]]
59 ; CHECK-NEXT: [[COND_1:%.*]] = select i1 [[CMP5_1]], i32 [[SUB_1]], i32 [[SUB7_1]]
60 ; CHECK-NEXT: [[CMP8_1:%.*]] = icmp sgt i32 [[SUB4_1]], -1
61 ; CHECK-NEXT: [[SUB12_1:%.*]] = sub nsw i32 128, [[CONV3_1]]
62 ; CHECK-NEXT: [[COND14_1:%.*]] = select i1 [[CMP8_1]], i32 [[SUB4_1]], i32 [[SUB12_1]]
63 ; CHECK-NEXT: [[ADD_1:%.*]] = add nsw i32 [[COND14_1]], [[COND_1]]
64 ; CHECK-NEXT: [[IDX_NEG_1:%.*]] = sub nsw i32 0, [[ADD_1]]
65 ; CHECK-NEXT: [[ADD_PTR_1:%.*]] = getelementptr inbounds i8, ptr [[ADD_PTR23]], i32 [[IDX_NEG_1]]
66 ; CHECK-NEXT: [[TMP10:%.*]] = load i8, ptr [[ADD_PTR_1]], align 1
67 ; CHECK-NEXT: [[CONV15_1:%.*]] = zext i8 [[TMP10]] to i32
68 ; CHECK-NEXT: [[ADD16_1:%.*]] = add nsw i32 [[CONV15_1]], [[INTENSITY]]
69 ; CHECK-NEXT: [[CONV17_1:%.*]] = trunc i32 [[ADD16_1]] to i8
70 ; CHECK-NEXT: store i8 [[CONV17_1]], ptr [[ADD_PTR_1]], align 1
71 ; CHECK-NEXT: [[ADD_PTR18_1:%.*]] = getelementptr inbounds i8, ptr [[ADD_PTR23]], i32 [[ADD_1]]
72 ; CHECK-NEXT: [[TMP11:%.*]] = load i8, ptr [[ADD_PTR18_1]], align 1
73 ; CHECK-NEXT: [[NOT_TOBOOL_1:%.*]] = icmp eq i8 [[TMP11]], 0
74 ; CHECK-NEXT: [[CONV21_1:%.*]] = zext i1 [[NOT_TOBOOL_1]] to i8
75 ; CHECK-NEXT: store i8 [[CONV21_1]], ptr [[ADD_PTR18_1]], align 1
76 ; CHECK-NEXT: [[ADD_PTR23_1]] = getelementptr inbounds i8, ptr [[ADD_PTR23]], i32 [[TMP1]]
77 ; CHECK-NEXT: [[INC_1]] = add nsw i32 [[Y_045]], 2
78 ; CHECK-NEXT: [[EXITCOND_1:%.*]] = icmp eq i32 [[INC_1]], 128
79 ; CHECK-NEXT: br i1 [[EXITCOND_1]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
82 %0 = load i32, ptr @shift, align 4
83 %1 = load i32, ptr getelementptr inbounds ([10 x i32], ptr @shift, i32 0, i32 1), align 4
84 %2 = load ptr, ptr @data, align 4
85 %3 = load ptr, ptr getelementptr inbounds ([10 x ptr], ptr @data, i32 0, i32 1), align 4
87 %arrayidx = getelementptr inbounds i8, ptr %2, i32 %shr
88 %shr1 = lshr i32 1, %1
89 %arrayidx2 = getelementptr inbounds i8, ptr %3, i32 %shr1
92 for.cond.cleanup: ; preds = %for.body
95 for.body: ; preds = %for.body, %entry
96 %d1_data.046 = phi ptr [ %3, %entry ], [ %add.ptr23.1, %for.body ]
97 %y.045 = phi i32 [ 0, %entry ], [ %inc.1, %for.body ]
98 %4 = load i8, ptr %arrayidx, align 1
99 %conv = zext i8 %4 to i32
100 %sub = add nsw i32 %conv, -128
101 %5 = load i8, ptr %arrayidx2, align 1
102 %conv3 = zext i8 %5 to i32
103 %sub4 = add nsw i32 %conv3, -128
104 %cmp5 = icmp sgt i32 %sub, -1
105 %sub7 = sub nsw i32 128, %conv
106 %cond = select i1 %cmp5, i32 %sub, i32 %sub7
107 %cmp8 = icmp sgt i32 %sub4, -1
108 %sub12 = sub nsw i32 128, %conv3
109 %cond14 = select i1 %cmp8, i32 %sub4, i32 %sub12
110 %add = add nsw i32 %cond14, %cond
111 %idx.neg = sub nsw i32 0, %add
112 %add.ptr = getelementptr inbounds i8, ptr %d1_data.046, i32 %idx.neg
113 %6 = load i8, ptr %add.ptr, align 1
114 %conv15 = zext i8 %6 to i32
115 %add16 = add nsw i32 %conv15, %intensity
116 %conv17 = trunc i32 %add16 to i8
117 store i8 %conv17, ptr %add.ptr, align 1
118 %add.ptr18 = getelementptr inbounds i8, ptr %d1_data.046, i32 %add
119 %7 = load i8, ptr %add.ptr18, align 1
120 %not.tobool = icmp eq i8 %7, 0
121 %conv21 = zext i1 %not.tobool to i8
122 store i8 %conv21, ptr %add.ptr18, align 1
123 %add.ptr23 = getelementptr inbounds i8, ptr %d1_data.046, i32 %1
124 %8 = load i8, ptr %arrayidx, align 1
125 %conv.1 = zext i8 %8 to i32
126 %sub.1 = add nsw i32 %conv.1, -128
127 %9 = load i8, ptr %arrayidx2, align 1
128 %conv3.1 = zext i8 %9 to i32
129 %sub4.1 = add nsw i32 %conv3.1, -128
130 %cmp5.1 = icmp sgt i32 %sub.1, -1
131 %sub7.1 = sub nsw i32 128, %conv.1
132 %cond.1 = select i1 %cmp5.1, i32 %sub.1, i32 %sub7.1
133 %cmp8.1 = icmp sgt i32 %sub4.1, -1
134 %sub12.1 = sub nsw i32 128, %conv3.1
135 %cond14.1 = select i1 %cmp8.1, i32 %sub4.1, i32 %sub12.1
136 %add.1 = add nsw i32 %cond14.1, %cond.1
137 %idx.neg.1 = sub nsw i32 0, %add.1
138 %add.ptr.1 = getelementptr inbounds i8, ptr %add.ptr23, i32 %idx.neg.1
139 %10 = load i8, ptr %add.ptr.1, align 1
140 %conv15.1 = zext i8 %10 to i32
141 %add16.1 = add nsw i32 %conv15.1, %intensity
142 %conv17.1 = trunc i32 %add16.1 to i8
143 store i8 %conv17.1, ptr %add.ptr.1, align 1
144 %add.ptr18.1 = getelementptr inbounds i8, ptr %add.ptr23, i32 %add.1
145 %11 = load i8, ptr %add.ptr18.1, align 1
146 %not.tobool.1 = icmp eq i8 %11, 0
147 %conv21.1 = zext i1 %not.tobool.1 to i8
148 store i8 %conv21.1, ptr %add.ptr18.1, align 1
149 %add.ptr23.1 = getelementptr inbounds i8, ptr %add.ptr23, i32 %1
150 %inc.1 = add nsw i32 %y.045, 2
151 %exitcond.1 = icmp eq i32 %inc.1, 128
152 br i1 %exitcond.1, label %for.cond.cleanup, label %for.body