blob: 53703ccea7cbddc1d015d056edc6aa5258116440 [file] [log] [blame]
Sanjay Patelb653de12014-09-10 17:58:16 +00001; RUN: opt < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s
Nadav Rotem5bed7b42012-10-23 18:44:18 +00002
3target 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"
Nadav Rotem5bed7b42012-10-23 18:44:18 +00004
Stephen Linc1c7a132013-07-14 01:42:54 +00005;CHECK-LABEL: @cpp_new_arrays(
Nadav Roteme266efb2012-12-11 18:58:10 +00006;CHECK: sext i32
Nadav Rotem5bed7b42012-10-23 18:44:18 +00007;CHECK: load <4 x float>
8;CHECK: fadd <4 x float>
9;CHECK: ret i32
10define i32 @cpp_new_arrays() uwtable ssp {
11entry:
12 %call = call noalias i8* @_Znwm(i64 4)
13 %0 = bitcast i8* %call to float*
14 store float 1.000000e+03, float* %0, align 4
15 %call1 = call noalias i8* @_Znwm(i64 4)
16 %1 = bitcast i8* %call1 to float*
17 store float 1.000000e+03, float* %1, align 4
18 %call3 = call noalias i8* @_Znwm(i64 4)
19 %2 = bitcast i8* %call3 to float*
20 store float 1.000000e+03, float* %2, align 4
21 br label %for.body
22
23for.body: ; preds = %entry, %for.body
24 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
25 %idxprom = sext i32 %i.01 to i64
David Blaikie79e6c742015-02-27 19:29:02 +000026 %arrayidx = getelementptr inbounds float, float* %0, i64 %idxprom
David Blaikiea79ac142015-02-27 21:17:42 +000027 %3 = load float, float* %arrayidx, align 4
Nadav Rotem5bed7b42012-10-23 18:44:18 +000028 %idxprom5 = sext i32 %i.01 to i64
David Blaikie79e6c742015-02-27 19:29:02 +000029 %arrayidx6 = getelementptr inbounds float, float* %1, i64 %idxprom5
David Blaikiea79ac142015-02-27 21:17:42 +000030 %4 = load float, float* %arrayidx6, align 4
Nadav Rotem5bed7b42012-10-23 18:44:18 +000031 %add = fadd float %3, %4
32 %idxprom7 = sext i32 %i.01 to i64
David Blaikie79e6c742015-02-27 19:29:02 +000033 %arrayidx8 = getelementptr inbounds float, float* %2, i64 %idxprom7
Nadav Rotem5bed7b42012-10-23 18:44:18 +000034 store float %add, float* %arrayidx8, align 4
35 %inc = add nsw i32 %i.01, 1
36 %cmp = icmp slt i32 %inc, 1000
37 br i1 %cmp, label %for.body, label %for.end
38
39for.end: ; preds = %for.body
David Blaikiea79ac142015-02-27 21:17:42 +000040 %5 = load float, float* %2, align 4
Nadav Rotem5bed7b42012-10-23 18:44:18 +000041 %conv10 = fptosi float %5 to i32
42 ret i32 %conv10
43}
44
45declare noalias i8* @_Znwm(i64)