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 slp-perm-3.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer slp-perm-3.s > slp-perm-3.ll
6 ; ModuleID = 'slp-perm-3.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 @main.check_results = internal unnamed_addr constant [16 x i32] [i32 1872, i32 746, i32 28304, i32 4815, i32 8392, i32 2894, i32 139524, i32 18411, i32 14912, i32 5042, i32 250744, i32 32007, i32 21432, i32 7190, i32 361964, i32 45603], align 16
12 define void @foo(i32* noalias %pInput, i32* noalias %pOutput) nounwind uwtable {
16 for.cond: ; preds = %for.inc, %entry
17 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
18 %tmp = mul i64 %indvar, 4
19 %tmp1 = add i64 %tmp, 3
20 %incdec.ptr48 = getelementptr i32* %pOutput, i64 %tmp1
21 %tmp3 = add i64 %tmp, 2
22 %incdec.ptr35 = getelementptr i32* %pOutput, i64 %tmp3
23 %tmp4 = add i64 %tmp, 1
24 %incdec.ptr22 = getelementptr i32* %pOutput, i64 %tmp4
25 %pOutput.addr.0 = getelementptr i32* %pOutput, i64 %tmp
26 %incdec.ptr7 = getelementptr i32* %pInput, i64 %tmp1
27 %incdec.ptr4 = getelementptr i32* %pInput, i64 %tmp3
28 %incdec.ptr = getelementptr i32* %pInput, i64 %tmp4
29 %pInput.addr.0 = getelementptr i32* %pInput, i64 %tmp
30 %exitcond = icmp ne i64 %indvar, 4
31 br i1 %exitcond, label %for.body, label %for.end
33 for.body: ; preds = %for.cond
34 %tmp2 = load i32* %pInput.addr.0, align 4
35 %tmp5 = load i32* %incdec.ptr, align 4
36 %tmp8 = load i32* %incdec.ptr4, align 4
37 %tmp11 = load i32* %incdec.ptr7, align 4
38 %mul = mul i32 %tmp2, 100
39 %mul14 = mul i32 %tmp5, 1322
40 %add = add i32 %mul, %mul14
41 %mul16 = mul i32 %tmp8, 74
42 %add17 = add i32 %add, %mul16
43 %mul19 = mul i32 %tmp11, 134
44 %add20 = add i32 %add17, %mul19
45 store i32 %add20, i32* %pOutput.addr.0, align 4
46 %mul24 = mul i32 %tmp2, 216
47 %mul26 = mul i32 %tmp5, 13
48 %add27 = add i32 %mul24, %mul26
49 %mul29 = mul i32 %tmp8, 191
50 %add30 = add i32 %add27, %mul29
51 %mul32 = mul i32 %tmp11, 117
52 %add33 = add i32 %add30, %mul32
53 store i32 %add33, i32* %incdec.ptr22, align 4
54 %mul37 = mul i32 %tmp2, 23
55 %mul39 = mul i32 %tmp5, 27271
56 %add40 = add i32 %mul37, %mul39
57 %mul42 = mul i32 %tmp8, 500
58 %add43 = add i32 %add40, %mul42
59 %mul45 = mul i32 %tmp11, 11
60 %add46 = add i32 %add43, %mul45
61 store i32 %add46, i32* %incdec.ptr35, align 4
62 %mul50 = mul i32 %tmp2, 237
63 %mul52 = mul i32 %tmp5, 2280
64 %add53 = add i32 %mul50, %mul52
65 %mul55 = mul i32 %tmp8, 111
66 %add56 = add i32 %add53, %mul55
67 %mul58 = mul i32 %tmp11, 771
68 %add59 = add i32 %add56, %mul58
69 store i32 %add59, i32* %incdec.ptr48, align 4
72 for.inc: ; preds = %for.body
73 %indvar.next = add i64 %indvar, 1
76 for.end: ; preds = %for.cond
80 define i32 @main(i32 %argc, i8** %argv) nounwind uwtable {
82 %input = alloca [16 x i32], align 16
83 %output = alloca [16 x i32], align 16
84 %check_results = alloca [16 x i32], align 16
85 %tmp = bitcast [16 x i32]* %check_results to i8*
86 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([16 x i32]* @main.check_results to i8*), i64 64, i32 16, i1 false)
87 call void @check_vect()
90 for.cond: ; preds = %for.inc, %entry
91 %indvar2 = phi i64 [ %indvar.next3, %for.inc ], [ 0, %entry ]
92 %i.0 = trunc i64 %indvar2 to i32
93 %arrayidx6 = getelementptr [16 x i32]* %output, i64 0, i64 %indvar2
94 %arrayidx = getelementptr [16 x i32]* %input, i64 0, i64 %indvar2
95 %exitcond = icmp ne i64 %indvar2, 16
96 br i1 %exitcond, label %for.body, label %for.end
98 for.body: ; preds = %for.cond
99 store i32 %i.0, i32* %arrayidx, align 4
100 store i32 0, i32* %arrayidx6, align 4
101 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
104 for.inc: ; preds = %for.body
105 %indvar.next3 = add i64 %indvar2, 1
108 for.end: ; preds = %for.cond
109 %arraydecay = getelementptr inbounds [16 x i32]* %input, i64 0, i64 0
110 %arraydecay8 = getelementptr inbounds [16 x i32]* %output, i64 0, i64 0
111 call void @foo(i32* %arraydecay, i32* %arraydecay8)
114 for.cond9: ; preds = %for.inc22, %for.end
115 %indvar = phi i64 [ %indvar.next, %for.inc22 ], [ 0, %for.end ]
116 %arrayidx19 = getelementptr [16 x i32]* %check_results, i64 0, i64 %indvar
117 %arrayidx15 = getelementptr [16 x i32]* %output, i64 0, i64 %indvar
118 %i.1 = trunc i64 %indvar to i32
119 %cmp11 = icmp ult i32 %i.1, 16
120 br i1 %cmp11, label %for.body12, label %for.end25
122 for.body12: ; preds = %for.cond9
123 %tmp16 = load i32* %arrayidx15, align 4
124 %tmp20 = load i32* %arrayidx19, align 4
125 %cmp21 = icmp eq i32 %tmp16, %tmp20
126 br i1 %cmp21, label %if.end, label %if.then
128 if.then: ; preds = %for.body12
129 call void @abort() noreturn nounwind
132 if.end: ; preds = %for.body12
133 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !1
136 for.inc22: ; preds = %if.end
137 %indvar.next = add i64 %indvar, 1
140 for.end25: ; preds = %for.cond9
144 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
146 define internal void @check_vect() nounwind uwtable noinline {
148 %a = alloca i32, align 4
149 %b = alloca i32, align 4
150 %c = alloca i32, align 4
151 %d = alloca i32, align 4
152 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
153 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
154 %tobool = icmp eq i32 %call1, 0
155 br i1 %tobool, label %if.then, label %lor.lhs.false
157 lor.lhs.false: ; preds = %entry
158 %tmp4 = load i32* %d, align 4
159 %and6 = and i32 %tmp4, 67108864
160 %cmp = icmp eq i32 %and6, 0
161 br i1 %cmp, label %if.then, label %if.end
163 if.then: ; preds = %entry, %lor.lhs.false
164 call void @exit(i32 0) noreturn nounwind
167 if.end: ; preds = %lor.lhs.false
168 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
172 declare void @abort() noreturn
174 declare void (i32)* @signal(i32, void (i32)*) nounwind
176 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
178 call void @exit(i32 0) noreturn nounwind
181 return: ; No predecessors!
185 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
187 %and = and i32 %__level, -2147483648
188 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
189 %cmp = icmp ult i32 %call, %__level
190 br i1 %cmp, label %if.then, label %if.end
192 if.then: ; preds = %entry
195 if.end: ; preds = %entry
196 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !2
197 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
198 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
199 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
200 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
201 store i32 %asmresult, i32* %__eax, align 4
202 store i32 %asmresult8, i32* %__ebx, align 4
203 store i32 %asmresult9, i32* %__ecx, align 4
204 store i32 %asmresult10, i32* %__edx, align 4
207 return: ; preds = %if.end, %if.then
208 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
212 declare void @exit(i32) noreturn
214 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
216 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !3
217 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
218 %tobool = icmp eq i32* %__sig, null
219 br i1 %tobool, label %if.end, label %if.then
221 if.then: ; preds = %entry
222 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
223 store i32 %asmresult1, i32* %__sig, align 4
226 if.end: ; preds = %entry, %if.then
230 !0 = metadata !{i32 1193}
231 !1 = metadata !{i32 1337}
232 !2 = metadata !{i32 -2147342710, i32 -2147342702}
233 !3 = metadata !{i32 -2147342833, i32 -2147342825}