1 ; RUN: opt %loadPolly %defaultOpts -polly-codegen -enable-polly-vector -dce -S %s | FileCheck %s
2 ; Obtained from C source as:
3 ; clang -S -emit-llvm -O0 vect-widen-mult-const-u16.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-widen-mult-const-u16.s > vect-widen-mult-const-u16.ll
6 ; ModuleID = 'vect-widen-mult-const-u16.s'
7 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"
8 target triple = "x86_64-unknown-linux-gnu"
10 define void @foo(i32* noalias %a, i16* noalias %b, i32 %n) nounwind uwtable noinline {
12 %tmp = icmp sgt i32 %n, 0
13 %smax = select i1 %tmp, i32 %n, i32 0
14 %tmp3 = zext i32 %smax to i64
17 for.cond: ; preds = %for.inc, %entry
18 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
19 %arrayidx8 = getelementptr i32* %a, i64 %indvar1
20 %arrayidx = getelementptr i16* %b, i64 %indvar1
21 %exitcond = icmp ne i64 %indvar1, %tmp3
22 br i1 %exitcond, label %for.body, label %for.end
24 for.body: ; preds = %for.cond
25 %tmp4 = load i16* %arrayidx, align 2
26 %conv = zext i16 %tmp4 to i32
27 %mul = mul nsw i32 %conv, 2333
28 store i32 %mul, i32* %arrayidx8, align 4
31 for.inc: ; preds = %for.body
32 %indvar.next2 = add i64 %indvar1, 1
35 for.end: ; preds = %for.cond
38 for.cond10: ; preds = %for.inc30, %for.end
39 %indvar = phi i64 [ %indvar.next, %for.inc30 ], [ 0, %for.end ]
40 %arrayidx24 = getelementptr i16* %b, i64 %indvar
41 %arrayidx19 = getelementptr i32* %a, i64 %indvar
42 %i.1 = trunc i64 %indvar to i32
43 %cmp13 = icmp slt i32 %i.1, %n
44 br i1 %cmp13, label %for.body15, label %for.end33
46 for.body15: ; preds = %for.cond10
47 %tmp20 = load i32* %arrayidx19, align 4
48 %tmp25 = load i16* %arrayidx24, align 2
49 %conv26 = zext i16 %tmp25 to i32
50 %mul27 = mul nsw i32 %conv26, 2333
51 %cmp28 = icmp eq i32 %tmp20, %mul27
52 br i1 %cmp28, label %if.end, label %if.then
54 if.then: ; preds = %for.body15
55 call void @abort() noreturn nounwind
58 if.end: ; preds = %for.body15
61 for.inc30: ; preds = %if.end
62 %indvar.next = add i64 %indvar, 1
65 for.end33: ; preds = %for.cond10
69 declare void @abort() noreturn nounwind
71 define void @bar(i32* noalias %a, i16* noalias %b, i32 %n) nounwind uwtable noinline {
73 %tmp = icmp sgt i32 %n, 0
74 %smax = select i1 %tmp, i32 %n, i32 0
75 %tmp3 = zext i32 %smax to i64
78 for.cond: ; preds = %for.inc, %entry
79 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
80 %arrayidx8 = getelementptr i32* %a, i64 %indvar1
81 %arrayidx = getelementptr i16* %b, i64 %indvar1
82 %exitcond = icmp ne i64 %indvar1, %tmp3
83 br i1 %exitcond, label %for.body, label %for.end
85 for.body: ; preds = %for.cond
86 %tmp4 = load i16* %arrayidx, align 2
87 %conv = zext i16 %tmp4 to i32
88 %mul = mul nsw i32 %conv, 2333
89 store i32 %mul, i32* %arrayidx8, align 4
92 for.inc: ; preds = %for.body
93 %indvar.next2 = add i64 %indvar1, 1
96 for.end: ; preds = %for.cond
99 for.cond10: ; preds = %for.inc30, %for.end
100 %indvar = phi i64 [ %indvar.next, %for.inc30 ], [ 0, %for.end ]
101 %arrayidx24 = getelementptr i16* %b, i64 %indvar
102 %arrayidx19 = getelementptr i32* %a, i64 %indvar
103 %i.1 = trunc i64 %indvar to i32
104 %cmp13 = icmp slt i32 %i.1, %n
105 br i1 %cmp13, label %for.body15, label %for.end33
107 for.body15: ; preds = %for.cond10
108 %tmp20 = load i32* %arrayidx19, align 4
109 %tmp25 = load i16* %arrayidx24, align 2
110 %conv26 = zext i16 %tmp25 to i32
111 %mul27 = mul nsw i32 %conv26, 2333
112 %cmp28 = icmp eq i32 %tmp20, %mul27
113 br i1 %cmp28, label %if.end, label %if.then
115 if.then: ; preds = %for.body15
116 call void @abort() noreturn nounwind
119 if.end: ; preds = %for.body15
122 for.inc30: ; preds = %if.end
123 %indvar.next = add i64 %indvar, 1
126 for.end33: ; preds = %for.cond10
130 define void @baz(i32* noalias %a, i16* noalias %b, i32 %n) nounwind uwtable noinline {
132 %tmp = icmp sgt i32 %n, 0
133 %smax = select i1 %tmp, i32 %n, i32 0
134 %tmp3 = zext i32 %smax to i64
137 for.cond: ; preds = %for.inc, %entry
138 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
139 %arrayidx8 = getelementptr i32* %a, i64 %indvar1
140 %arrayidx = getelementptr i16* %b, i64 %indvar1
141 %exitcond = icmp ne i64 %indvar1, %tmp3
142 br i1 %exitcond, label %for.body, label %for.end
144 for.body: ; preds = %for.cond
145 %tmp4 = load i16* %arrayidx, align 2
146 %conv = zext i16 %tmp4 to i32
147 %mul = mul nsw i32 %conv, 233333333
148 store i32 %mul, i32* %arrayidx8, align 4
151 for.inc: ; preds = %for.body
152 %indvar.next2 = add i64 %indvar1, 1
155 for.end: ; preds = %for.cond
158 for.cond10: ; preds = %for.inc30, %for.end
159 %indvar = phi i64 [ %indvar.next, %for.inc30 ], [ 0, %for.end ]
160 %arrayidx24 = getelementptr i16* %b, i64 %indvar
161 %arrayidx19 = getelementptr i32* %a, i64 %indvar
162 %i.1 = trunc i64 %indvar to i32
163 %cmp13 = icmp slt i32 %i.1, %n
164 br i1 %cmp13, label %for.body15, label %for.end33
166 for.body15: ; preds = %for.cond10
167 %tmp20 = load i32* %arrayidx19, align 4
168 %tmp25 = load i16* %arrayidx24, align 2
169 %conv26 = zext i16 %tmp25 to i32
170 %mul27 = mul nsw i32 %conv26, 233333333
171 %cmp28 = icmp eq i32 %tmp20, %mul27
172 br i1 %cmp28, label %if.end, label %if.then
174 if.then: ; preds = %for.body15
175 call void @abort() noreturn nounwind
178 if.end: ; preds = %for.body15
181 for.inc30: ; preds = %if.end
182 %indvar.next = add i64 %indvar, 1
185 for.end33: ; preds = %for.cond10
189 define i32 @main() nounwind uwtable {
191 %a = alloca [32 x i32], align 16
192 %b = alloca [32 x i16], align 16
195 for.cond: ; preds = %for.inc, %entry
196 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
197 %arrayidx5 = getelementptr [32 x i16]* %b, i64 0, i64 %indvar
198 %conv = trunc i64 %indvar to i16
199 %arrayidx = getelementptr [32 x i32]* %a, i64 0, i64 %indvar
200 %exitcond = icmp ne i64 %indvar, 32
201 br i1 %exitcond, label %for.body, label %for.end
203 for.body: ; preds = %for.cond
204 store i32 0, i32* %arrayidx, align 4
205 store i16 %conv, i16* %arrayidx5, align 2
206 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
209 for.inc: ; preds = %for.body
210 %indvar.next = add i64 %indvar, 1
213 for.end: ; preds = %for.cond
214 %arraydecay = getelementptr inbounds [32 x i32]* %a, i64 0, i64 0
215 %arraydecay7 = getelementptr inbounds [32 x i16]* %b, i64 0, i64 0
216 call void @foo(i32* %arraydecay, i16* %arraydecay7, i32 32)
217 %arraydecay8 = getelementptr inbounds [32 x i32]* %a, i64 0, i64 0
218 %arraydecay9 = getelementptr inbounds [32 x i16]* %b, i64 0, i64 0
219 call void @bar(i32* %arraydecay8, i16* %arraydecay9, i32 32)
220 %arraydecay10 = getelementptr inbounds [32 x i32]* %a, i64 0, i64 0
221 %arraydecay11 = getelementptr inbounds [32 x i16]* %b, i64 0, i64 0
222 call void @baz(i32* %arraydecay10, i16* %arraydecay11, i32 32)
226 !0 = metadata !{i32 1061}