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-ifcvt-9.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-ifcvt-9.s > vect-ifcvt-9.ll
6 ; ModuleID = 'vect-ifcvt-9.s'
8 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"
9 target triple = "x86_64-unknown-linux-gnu"
11 @A = global [16 x i32] [i32 36, i32 39, i32 42, i32 45, i32 43, i32 32, i32 21, i32 12, i32 23, i32 34, i32 45, i32 56, i32 67, i32 78, i32 89, i32 11], align 16
12 @B = global [16 x i32] [i32 0, i32 0, i32 42, i32 42, i32 42, i32 0, i32 0, i32 0, i32 0, i32 0, i32 42, i32 42, i32 42, i32 42, i32 42, i32 0], align 16
14 define void @foo() nounwind uwtable inlinehint alwaysinline {
18 for.cond: ; preds = %for.inc, %entry
19 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
20 %arrayidx = getelementptr [16 x i32]* @A, i64 0, i64 %indvar
21 %exitcond = icmp ne i64 %indvar, 16
22 br i1 %exitcond, label %for.body, label %for.end
24 for.body: ; preds = %for.cond
25 %tmp2 = load i32* %arrayidx, align 4
26 %cmp3 = icmp sgt i32 %tmp2, 41
27 %cond = select i1 %cmp3, i32 42, i32 0
28 store i32 %cond, i32* %arrayidx, align 4
31 for.inc: ; preds = %for.body
32 %indvar.next = add i64 %indvar, 1
35 for.end: ; preds = %for.cond
39 define i32 @main() nounwind uwtable {
41 call void @check_vect()
44 for.cond.i: ; preds = %for.body.i, %entry
45 %indvar1 = phi i64 [ %indvar.next2, %for.body.i ], [ 0, %entry ]
46 %arrayidx.i = getelementptr [16 x i32]* @A, i64 0, i64 %indvar1
47 %exitcond = icmp ne i64 %indvar1, 16
48 br i1 %exitcond, label %for.body.i, label %foo.exit
50 for.body.i: ; preds = %for.cond.i
51 %tmp2.i = load i32* %arrayidx.i, align 4
52 %cmp3.i = icmp sgt i32 %tmp2.i, 41
53 %cond.i = select i1 %cmp3.i, i32 42, i32 0
54 store i32 %cond.i, i32* %arrayidx.i, align 4
55 %indvar.next2 = add i64 %indvar1, 1
58 foo.exit: ; preds = %for.cond.i
61 for.cond: ; preds = %for.inc, %foo.exit
62 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %foo.exit ]
63 %arrayidx5 = getelementptr [16 x i32]* @B, i64 0, i64 %indvar
64 %arrayidx = getelementptr [16 x i32]* @A, i64 0, i64 %indvar
65 %i.0 = trunc i64 %indvar to i32
66 %cmp = icmp slt i32 %i.0, 16
67 br i1 %cmp, label %for.body, label %for.end
69 for.body: ; preds = %for.cond
70 %tmp2 = load i32* %arrayidx, align 4
71 %tmp6 = load i32* %arrayidx5, align 4
72 %cmp7 = icmp eq i32 %tmp2, %tmp6
73 br i1 %cmp7, label %if.end, label %if.then
75 if.then: ; preds = %for.body
76 call void @abort() noreturn nounwind
79 if.end: ; preds = %for.body
82 for.inc: ; preds = %if.end
83 %indvar.next = add i64 %indvar, 1
86 for.end: ; preds = %for.cond
90 define internal void @check_vect() nounwind uwtable noinline {
92 %a = alloca i32, align 4
93 %b = alloca i32, align 4
94 %c = alloca i32, align 4
95 %d = alloca i32, align 4
96 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
97 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
98 %tobool = icmp eq i32 %call1, 0
99 br i1 %tobool, label %if.then, label %lor.lhs.false
101 lor.lhs.false: ; preds = %entry
102 %tmp4 = load i32* %d, align 4
103 %and6 = and i32 %tmp4, 67108864
104 %cmp = icmp eq i32 %and6, 0
105 br i1 %cmp, label %if.then, label %if.end
107 if.then: ; preds = %entry, %lor.lhs.false
108 call void @exit(i32 0) noreturn nounwind
111 if.end: ; preds = %lor.lhs.false
112 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
116 declare void @abort() noreturn
118 declare void (i32)* @signal(i32, void (i32)*) nounwind
120 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
122 call void @exit(i32 0) noreturn nounwind
125 return: ; No predecessors!
129 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
131 %and = and i32 %__level, -2147483648
132 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
133 %cmp = icmp ult i32 %call, %__level
134 br i1 %cmp, label %if.then, label %if.end
136 if.then: ; preds = %entry
139 if.end: ; preds = %entry
140 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
141 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
142 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
143 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
144 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
145 store i32 %asmresult, i32* %__eax, align 4
146 store i32 %asmresult8, i32* %__ebx, align 4
147 store i32 %asmresult9, i32* %__ecx, align 4
148 store i32 %asmresult10, i32* %__edx, align 4
151 return: ; preds = %if.end, %if.then
152 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
156 declare void @exit(i32) noreturn
158 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
160 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
161 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
162 %tobool = icmp eq i32* %__sig, null
163 br i1 %tobool, label %if.end, label %if.then
165 if.then: ; preds = %entry
166 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
167 store i32 %asmresult1, i32* %__sig, align 4
170 if.end: ; preds = %entry, %if.then
174 declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
176 declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
178 !0 = metadata !{i32 -2147343556, i32 -2147343548}
179 !1 = metadata !{i32 -2147343679, i32 -2147343671}