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-widen-mult-u8.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-widen-mult-u8.s > vect-widen-mult-u8.ll
6 ; ModuleID = 'vect-widen-mult-u8.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 i8] zeroinitializer, align 16
11 @Y = common global [64 x i8] zeroinitializer, align 16
12 @result = common global [64 x i16] zeroinitializer, align 16
14 define i32 @foo1(i32 %len) nounwind uwtable noinline {
16 %tmp = icmp sgt i32 %len, 0
17 %smax = select i1 %tmp, i32 %len, i32 0
18 %tmp1 = zext i32 %smax to i64
21 for.cond: ; preds = %for.inc, %entry
22 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
23 %arrayidx12 = getelementptr [64 x i16]* @result, i64 0, i64 %indvar
24 %arrayidx6 = getelementptr [64 x i8]* @Y, i64 0, i64 %indvar
25 %arrayidx = getelementptr [64 x i8]* @X, i64 0, i64 %indvar
26 %exitcond = icmp ne i64 %indvar, %tmp1
27 br i1 %exitcond, label %for.body, label %for.end
29 for.body: ; preds = %for.cond
30 %tmp3 = load i8* %arrayidx, align 1
31 %conv = zext i8 %tmp3 to i16
32 %tmp7 = load i8* %arrayidx6, align 1
33 %conv8 = zext i8 %tmp7 to i16
34 %mul = mul i16 %conv, %conv8
35 store i16 %mul, i16* %arrayidx12, align 2
38 for.inc: ; preds = %for.body
39 %indvar.next = add i64 %indvar, 1
42 for.end: ; preds = %for.cond
46 define i32 @main() nounwind uwtable {
48 call void @check_vect()
51 for.cond: ; preds = %for.inc, %entry
52 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
53 %arrayidx7 = getelementptr [64 x i8]* @Y, i64 0, i64 %indvar1
54 %tmp = mul i64 %indvar1, -1
55 %tmp3 = add i64 %tmp, 64
56 %conv4 = trunc i64 %tmp3 to i8
57 %arrayidx = getelementptr [64 x i8]* @X, i64 0, i64 %indvar1
58 %conv = trunc i64 %indvar1 to i8
59 %exitcond = icmp ne i64 %indvar1, 64
60 br i1 %exitcond, label %for.body, label %for.end
62 for.body: ; preds = %for.cond
63 store i8 %conv, i8* %arrayidx, align 1
64 store i8 %conv4, i8* %arrayidx7, align 1
65 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
68 for.inc: ; preds = %for.body
69 %indvar.next2 = add i64 %indvar1, 1
72 for.end: ; preds = %for.cond
73 %call = call i32 @foo1(i32 64)
76 for.cond9: ; preds = %for.inc31, %for.end
77 %indvar = phi i64 [ %indvar.next, %for.inc31 ], [ 0, %for.end ]
78 %arrayidx26 = getelementptr [64 x i8]* @Y, i64 0, i64 %indvar
79 %arrayidx21 = getelementptr [64 x i8]* @X, i64 0, i64 %indvar
80 %arrayidx16 = getelementptr [64 x i16]* @result, i64 0, i64 %indvar
81 %i.1 = trunc i64 %indvar to i32
82 %cmp11 = icmp slt i32 %i.1, 64
83 br i1 %cmp11, label %for.body13, label %for.end34
85 for.body13: ; preds = %for.cond9
86 %tmp17 = load i16* %arrayidx16, align 2
87 %conv18 = zext i16 %tmp17 to i32
88 %tmp22 = load i8* %arrayidx21, align 1
89 %conv23 = zext i8 %tmp22 to i32
90 %tmp27 = load i8* %arrayidx26, align 1
91 %conv28 = zext i8 %tmp27 to i32
92 %mul = mul nsw i32 %conv23, %conv28
93 %cmp29 = icmp eq i32 %conv18, %mul
94 br i1 %cmp29, label %if.end, label %if.then
96 if.then: ; preds = %for.body13
97 call void @abort() noreturn nounwind
100 if.end: ; preds = %for.body13
103 for.inc31: ; preds = %if.end
104 %indvar.next = add i64 %indvar, 1
107 for.end34: ; preds = %for.cond9
111 define internal void @check_vect() nounwind uwtable noinline {
113 %a = alloca i32, align 4
114 %b = alloca i32, align 4
115 %c = alloca i32, align 4
116 %d = alloca i32, align 4
117 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
118 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
119 %tobool = icmp eq i32 %call1, 0
120 br i1 %tobool, label %if.then, label %lor.lhs.false
122 lor.lhs.false: ; preds = %entry
123 %tmp4 = load i32* %d, align 4
124 %and6 = and i32 %tmp4, 67108864
125 %cmp = icmp eq i32 %and6, 0
126 br i1 %cmp, label %if.then, label %if.end
128 if.then: ; preds = %entry, %lor.lhs.false
129 call void @exit(i32 0) noreturn nounwind
132 if.end: ; preds = %lor.lhs.false
133 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
137 declare void @abort() noreturn
139 declare void (i32)* @signal(i32, void (i32)*) nounwind
141 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
143 call void @exit(i32 0) noreturn nounwind
146 return: ; No predecessors!
150 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
152 %and = and i32 %__level, -2147483648
153 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
154 %cmp = icmp ult i32 %call, %__level
155 br i1 %cmp, label %if.then, label %if.end
157 if.then: ; preds = %entry
160 if.end: ; preds = %entry
161 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !1
162 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
163 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
164 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
165 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
166 store i32 %asmresult, i32* %__eax, align 4
167 store i32 %asmresult8, i32* %__ebx, align 4
168 store i32 %asmresult9, i32* %__ecx, align 4
169 store i32 %asmresult10, i32* %__edx, align 4
172 return: ; preds = %if.end, %if.then
173 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
177 declare void @exit(i32) noreturn
179 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
181 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !2
182 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
183 %tobool = icmp eq i32* %__sig, null
184 br i1 %tobool, label %if.end, label %if.then
186 if.then: ; preds = %entry
187 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
188 store i32 %asmresult1, i32* %__sig, align 4
191 if.end: ; preds = %entry, %if.then
195 !0 = metadata !{i32 576}
196 !1 = metadata !{i32 -2147343194, i32 -2147343186}
197 !2 = metadata !{i32 -2147343317, i32 -2147343309}