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-reduc-dot-s16a.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-reduc-dot-s16a.s > vect-reduc-dot-s16a.ll
6 ; ModuleID = 'vect-reduc-dot-s16a.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 @X = common global [64 x i16] zeroinitializer, align 16
11 @Y = common global [64 x i16] zeroinitializer, align 16
13 define i32 @foo(i32 %len) nounwind uwtable noinline {
15 %tmp = icmp sgt i32 %len, 0
16 %smax = select i1 %tmp, i32 %len, i32 0
17 %tmp1 = zext i32 %smax to i64
20 for.cond: ; preds = %for.inc, %entry
21 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
22 %result.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
23 %arrayidx6 = getelementptr [64 x i16]* @Y, i64 0, i64 %indvar
24 %arrayidx = getelementptr [64 x i16]* @X, i64 0, i64 %indvar
25 %exitcond = icmp ne i64 %indvar, %tmp1
26 br i1 %exitcond, label %for.body, label %for.end
28 for.body: ; preds = %for.cond
31 for.inc: ; preds = %for.body
32 %tmp7 = load i16* %arrayidx6, align 2
33 %tmp3 = load i16* %arrayidx, align 2
34 %conv8 = sext i16 %tmp7 to i32
35 %conv = sext i16 %tmp3 to i32
36 %mul = mul nsw i32 %conv, %conv8
37 %add = add nsw i32 %result.0, %mul
38 %indvar.next = add i64 %indvar, 1
41 for.end: ; preds = %for.cond
42 %result.0.lcssa = phi i32 [ %result.0, %for.cond ]
43 ret i32 %result.0.lcssa
46 define i32 @main() nounwind uwtable {
48 call void @check_vect()
51 for.cond: ; preds = %for.inc, %entry
52 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
53 %arrayidx7 = getelementptr [64 x i16]* @Y, i64 0, i64 %indvar
54 %tmp = mul i64 %indvar, -1
55 %tmp1 = add i64 %tmp, 64
56 %conv4 = trunc i64 %tmp1 to i16
57 %arrayidx = getelementptr [64 x i16]* @X, i64 0, i64 %indvar
58 %conv = trunc i64 %indvar to i16
59 %exitcond = icmp ne i64 %indvar, 64
60 br i1 %exitcond, label %for.body, label %for.end
62 for.body: ; preds = %for.cond
63 store i16 %conv, i16* %arrayidx, align 2
64 store i16 %conv4, i16* %arrayidx7, align 2
65 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
68 for.inc: ; preds = %for.body
69 %indvar.next = add i64 %indvar, 1
72 for.end: ; preds = %for.cond
73 %call = call i32 @foo(i32 64)
74 %cmp10 = icmp eq i32 %call, 43680
75 br i1 %cmp10, label %if.end, label %if.then
77 if.then: ; preds = %for.end
78 call void @abort() noreturn nounwind
81 if.end: ; preds = %for.end
85 define internal void @check_vect() nounwind uwtable noinline {
87 %a = alloca i32, align 4
88 %b = alloca i32, align 4
89 %c = alloca i32, align 4
90 %d = alloca i32, align 4
91 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
92 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
93 %tobool = icmp eq i32 %call1, 0
94 br i1 %tobool, label %if.then, label %lor.lhs.false
96 lor.lhs.false: ; preds = %entry
97 %tmp4 = load i32* %d, align 4
98 %and6 = and i32 %tmp4, 67108864
99 %cmp = icmp eq i32 %and6, 0
100 br i1 %cmp, label %if.then, label %if.end
102 if.then: ; preds = %entry, %lor.lhs.false
103 call void @exit(i32 0) noreturn nounwind
106 if.end: ; preds = %lor.lhs.false
107 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
111 declare void @abort() noreturn
113 declare void (i32)* @signal(i32, void (i32)*) nounwind
115 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
117 call void @exit(i32 0) noreturn nounwind
120 return: ; No predecessors!
124 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
126 %and = and i32 %__level, -2147483648
127 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
128 %cmp = icmp ult i32 %call, %__level
129 br i1 %cmp, label %if.then, label %if.end
131 if.then: ; preds = %entry
134 if.end: ; preds = %entry
135 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !1
136 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
137 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
138 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
139 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
140 store i32 %asmresult, i32* %__eax, align 4
141 store i32 %asmresult8, i32* %__ebx, align 4
142 store i32 %asmresult9, i32* %__ecx, align 4
143 store i32 %asmresult10, i32* %__edx, align 4
146 return: ; preds = %if.end, %if.then
147 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
151 declare void @exit(i32) noreturn
153 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
155 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !2
156 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
157 %tobool = icmp eq i32* %__sig, null
158 br i1 %tobool, label %if.end, label %if.then
160 if.then: ; preds = %entry
161 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
162 store i32 %asmresult1, i32* %__sig, align 4
165 if.end: ; preds = %entry, %if.then
169 !0 = metadata !{i32 731}
170 !1 = metadata !{i32 -2147343166, i32 -2147343158}
171 !2 = metadata !{i32 -2147343289, i32 -2147343281}