1 ; RUN: opt -mattr=+avx512f --loop-vectorize -S < %s | llc -mattr=+avx512f | FileCheck %s
2 ; RUN: opt -mattr=+avx512vl,+prefer-256-bit --loop-vectorize -S < %s | llc -mattr=+avx512f | FileCheck %s --check-prefix=CHECK-PREFER-AVX256
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.9.0"
7 ; Verify that we generate 512-bit wide vectors for a basic integer memset
11 ; CHECK: vmovdqu64 %zmm{{.}},
14 ; Verify that we don't generate 512-bit wide vectors when subtarget feature says not to
16 ; CHECK-PREFER-AVX256-LABEL: f:
17 ; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
18 ; CHECK-PREFER-AVX256-NOT: %zmm
20 define void @f(i32* %a, i32 %n) {
22 %cmp4 = icmp sgt i32 %n, 0
23 br i1 %cmp4, label %for.body.preheader, label %for.end
25 for.body.preheader: ; preds = %entry
28 for.body: ; preds = %for.body.preheader, %for.body
29 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
30 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
31 store i32 %n, i32* %arrayidx, align 4
32 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
33 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
34 %exitcond = icmp eq i32 %lftr.wideiv, %n
35 br i1 %exitcond, label %for.end.loopexit, label %for.body
37 for.end.loopexit: ; preds = %for.body
40 for.end: ; preds = %for.end.loopexit, %entry
44 ; Verify that the "prefer-vector-width=256" attribute prevents the use of 512-bit
48 ; CHECK: vmovdqu %ymm{{.}},
51 ; CHECK-PREFER-AVX256-LABEL: g:
52 ; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
53 ; CHECK-PREFER-AVX256-NOT: %zmm
55 define void @g(i32* %a, i32 %n) "prefer-vector-width"="256" {
57 %cmp4 = icmp sgt i32 %n, 0
58 br i1 %cmp4, label %for.body.preheader, label %for.end
60 for.body.preheader: ; preds = %entry
63 for.body: ; preds = %for.body.preheader, %for.body
64 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
65 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
66 store i32 %n, i32* %arrayidx, align 4
67 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
68 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
69 %exitcond = icmp eq i32 %lftr.wideiv, %n
70 br i1 %exitcond, label %for.end.loopexit, label %for.body
72 for.end.loopexit: ; preds = %for.body
75 for.end: ; preds = %for.end.loopexit, %entry
79 ; Verify that the "prefer-vector-width=512" attribute override the subtarget
83 ; CHECK: vmovdqu64 %zmm{{.}},
86 ; CHECK-PREFER-AVX256-LABEL: h:
87 ; CHECK-PREFER-AVX256: vmovdqu64 %zmm{{.}},
88 ; CHECK-PREFER-AVX256-NOT: %ymm
90 define void @h(i32* %a, i32 %n) "prefer-vector-width"="512" {
92 %cmp4 = icmp sgt i32 %n, 0
93 br i1 %cmp4, label %for.body.preheader, label %for.end
95 for.body.preheader: ; preds = %entry
98 for.body: ; preds = %for.body.preheader, %for.body
99 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
100 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
101 store i32 %n, i32* %arrayidx, align 4
102 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
103 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
104 %exitcond = icmp eq i32 %lftr.wideiv, %n
105 br i1 %exitcond, label %for.end.loopexit, label %for.body
107 for.end.loopexit: ; preds = %for.body
110 for.end: ; preds = %for.end.loopexit, %entry