1 ; RUN: opt < %s -mcpu=core-avx2 -passes=loop-vectorize -S | llc -mcpu=core-avx2 | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx"
6 @float_array = common global [10000 x float] zeroinitializer, align 16
7 @unsigned_array = common global [10000 x i32] zeroinitializer, align 16
9 ; If we need to scalarize the fptoui and then use inserts to build up the
10 ; vector again, then there is certainly no value in going 256-bit wide.
11 ; CHECK-NOT: vinserti128
13 define void @convert(i32 %N) {
15 %0 = icmp eq i32 %N, 0
16 br i1 %0, label %for.end, label %for.body.preheader
18 for.body.preheader: ; preds = %entry
21 for.body: ; preds = %for.body.preheader, %for.body
22 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
23 %arrayidx = getelementptr inbounds [10000 x float], ptr @float_array, i64 0, i64 %indvars.iv
24 %1 = load float, ptr %arrayidx, align 4
25 %conv = fptoui float %1 to i32
26 %arrayidx2 = getelementptr inbounds [10000 x i32], ptr @unsigned_array, i64 0, i64 %indvars.iv
27 store i32 %conv, ptr %arrayidx2, align 4
28 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
29 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
30 %exitcond = icmp eq i32 %lftr.wideiv, %N
31 br i1 %exitcond, label %for.end.loopexit, label %for.body
33 for.end.loopexit: ; preds = %for.body
36 for.end: ; preds = %for.end.loopexit, %entry