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{{.}},
16 ; Verify that we don't generate 512-bit wide vectors when subtarget feature says not to
18 ; CHECK-PREFER-AVX256-LABEL: f:
19 ; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
20 ; CHECK-PREFER-AVX256-NOT: %zmm
22 define void @f(i32* %a, i32 %n) {
24 %cmp4 = icmp sgt i32 %n, 0
25 br i1 %cmp4, label %for.body.preheader, label %for.end
27 for.body.preheader: ; preds = %entry
30 for.body: ; preds = %for.body.preheader, %for.body
31 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
32 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
33 store i32 %n, i32* %arrayidx, align 4
34 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
35 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
36 %exitcond = icmp eq i32 %lftr.wideiv, %n
37 br i1 %exitcond, label %for.end.loopexit, label %for.body
39 for.end.loopexit: ; preds = %for.body
42 for.end: ; preds = %for.end.loopexit, %entry
46 ; Verify that the "prefer-vector-width=256" attribute prevents the use of 512-bit
50 ; CHECK: vmovdqu %ymm{{.}},
53 ; CHECK-PREFER-AVX256-LABEL: g:
54 ; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
55 ; CHECK-PREFER-AVX256-NOT: %zmm
57 define void @g(i32* %a, i32 %n) "prefer-vector-width"="256" {
59 %cmp4 = icmp sgt i32 %n, 0
60 br i1 %cmp4, label %for.body.preheader, label %for.end
62 for.body.preheader: ; preds = %entry
65 for.body: ; preds = %for.body.preheader, %for.body
66 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
67 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
68 store i32 %n, i32* %arrayidx, align 4
69 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
70 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
71 %exitcond = icmp eq i32 %lftr.wideiv, %n
72 br i1 %exitcond, label %for.end.loopexit, label %for.body
74 for.end.loopexit: ; preds = %for.body
77 for.end: ; preds = %for.end.loopexit, %entry
81 ; Verify that the "prefer-vector-width=512" attribute override the subtarget
85 ; CHECK: vmovdqu64 %zmm{{.}},
90 ; CHECK-PREFER-AVX256-LABEL: h:
91 ; CHECK-PREFER-AVX256: vmovdqu64 %zmm{{.}},
92 ; CHECK-PREFER-AVX256-NOT: %ymm
93 ; CHECK-PREFER-AVX256: epilog
94 ; CHECK-PREFER-AVX256: %ymm
96 define void @h(i32* %a, i32 %n) "prefer-vector-width"="512" {
98 %cmp4 = icmp sgt i32 %n, 0
99 br i1 %cmp4, label %for.body.preheader, label %for.end
101 for.body.preheader: ; preds = %entry
104 for.body: ; preds = %for.body.preheader, %for.body
105 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
106 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
107 store i32 %n, i32* %arrayidx, align 4
108 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
109 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
110 %exitcond = icmp eq i32 %lftr.wideiv, %n
111 br i1 %exitcond, label %for.end.loopexit, label %for.body
113 for.end.loopexit: ; preds = %for.body
116 for.end: ; preds = %for.end.loopexit, %entry