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-s16b.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-reduc-dot-s16b.s > vect-reduc-dot-s16b.ll
6 ; ModuleID = 'vect-reduc-dot-s16b.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 %mul = mul i16 %tmp3, %tmp7
35 %conv11 = sext i16 %mul to i32
36 %add = add nsw i32 %result.0, %conv11
37 %indvar.next = add i64 %indvar, 1
40 for.end: ; preds = %for.cond
41 %result.0.lcssa = phi i32 [ %result.0, %for.cond ]
42 ret i32 %result.0.lcssa
45 define i32 @main() nounwind uwtable {
47 call void @check_vect()
50 for.cond: ; preds = %for.inc, %entry
51 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
52 %arrayidx7 = getelementptr [64 x i16]* @Y, i64 0, i64 %indvar
53 %tmp = mul i64 %indvar, -1
54 %tmp1 = add i64 %tmp, 64
55 %conv4 = trunc i64 %tmp1 to i16
56 %arrayidx = getelementptr [64 x i16]* @X, i64 0, i64 %indvar
57 %conv = trunc i64 %indvar to i16
58 %exitcond = icmp ne i64 %indvar, 64
59 br i1 %exitcond, label %for.body, label %for.end
61 for.body: ; preds = %for.cond
62 store i16 %conv, i16* %arrayidx, align 2
63 store i16 %conv4, i16* %arrayidx7, align 2
64 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
67 for.inc: ; preds = %for.body
68 %indvar.next = add i64 %indvar, 1
71 for.end: ; preds = %for.cond
72 %call = call i32 @foo(i32 64)
73 %cmp10 = icmp eq i32 %call, 43680
74 br i1 %cmp10, label %if.end, label %if.then
76 if.then: ; preds = %for.end
77 call void @abort() noreturn nounwind
80 if.end: ; preds = %for.end
84 define internal void @check_vect() nounwind uwtable noinline {
86 %a = alloca i32, align 4
87 %b = alloca i32, align 4
88 %c = alloca i32, align 4
89 %d = alloca i32, align 4
90 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
91 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
92 %tobool = icmp eq i32 %call1, 0
93 br i1 %tobool, label %if.then, label %lor.lhs.false
95 lor.lhs.false: ; preds = %entry
96 %tmp4 = load i32* %d, align 4
97 %and6 = and i32 %tmp4, 67108864
98 %cmp = icmp eq i32 %and6, 0
99 br i1 %cmp, label %if.then, label %if.end
101 if.then: ; preds = %entry, %lor.lhs.false
102 call void @exit(i32 0) noreturn nounwind
105 if.end: ; preds = %lor.lhs.false
106 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
110 declare void @abort() noreturn
112 declare void (i32)* @signal(i32, void (i32)*) nounwind
114 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
116 call void @exit(i32 0) noreturn nounwind
119 return: ; No predecessors!
123 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
125 %and = and i32 %__level, -2147483648
126 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
127 %cmp = icmp ult i32 %call, %__level
128 br i1 %cmp, label %if.then, label %if.end
130 if.then: ; preds = %entry
133 if.end: ; preds = %entry
134 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !1
135 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
136 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
137 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
138 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
139 store i32 %asmresult, i32* %__eax, align 4
140 store i32 %asmresult8, i32* %__ebx, align 4
141 store i32 %asmresult9, i32* %__ecx, align 4
142 store i32 %asmresult10, i32* %__edx, align 4
145 return: ; preds = %if.end, %if.then
146 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
150 declare void @exit(i32) noreturn
152 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
154 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !2
155 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
156 %tobool = icmp eq i32* %__sig, null
157 br i1 %tobool, label %if.end, label %if.then
159 if.then: ; preds = %entry
160 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
161 store i32 %asmresult1, i32* %__sig, align 4
164 if.end: ; preds = %entry, %if.then
168 !0 = metadata !{i32 802}
169 !1 = metadata !{i32 -2147342997, i32 -2147342989}
170 !2 = metadata !{i32 -2147343120, i32 -2147343112}