1; RUN: opt < %s -mcpu=core-avx2 -loop-vectorize -S | llc -mcpu=core-avx2 | FileCheck %s
2
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-apple-macosx"
5
6@n = global i32 10000, align 4
7@double_array = common global [10000 x double] zeroinitializer, align 16
8@unsigned_array = common global [10000 x i32] zeroinitializer, align 16
9
10; If we need to scalarize the fptoui and then use inserts to build up the
11; vector again, then there is certainly no value in going 256-bit wide.
12; CHECK-NOT: vpinsrd
13
14define void @convert() {
15entry:
16  %0 = load i32, i32* @n, align 4
17  %cmp4 = icmp eq i32 %0, 0
18  br i1 %cmp4, label %for.end, label %for.body.preheader
19
20for.body.preheader:                               ; preds = %entry
21  br label %for.body
22
23for.body:                                         ; preds = %for.body.preheader, %for.body
24  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
25  %arrayidx = getelementptr inbounds [10000 x double], [10000 x double]* @double_array, i64 0, i64 %indvars.iv
26  %1 = load double, double* %arrayidx, align 8
27  %conv = fptoui double %1 to i32
28  %arrayidx2 = getelementptr inbounds [10000 x i32], [10000 x i32]* @unsigned_array, i64 0, i64 %indvars.iv
29  store i32 %conv, i32* %arrayidx2, align 4
30  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
31  %2 = trunc i64 %indvars.iv.next to i32
32  %cmp = icmp ult i32 %2, %0
33  br i1 %cmp, label %for.body, label %for.end.loopexit
34
35for.end.loopexit:                                 ; preds = %for.body
36  br label %for.end
37
38for.end:                                          ; preds = %for.end.loopexit, %entry
39  ret void
40}
41