• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
4target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-apple-macosx10.9.0"
6
7; Verify that we generate 512-bit wide vectors for a basic integer memset
8; loop.
9
10; CHECK-LABEL: f:
11; CHECK: vmovdqu64 %zmm{{.}},
12; CHECK-NOT: %ymm
13
14; Verify that we don't generate 512-bit wide vectors when subtarget feature says not to
15
16; CHECK-PREFER-AVX256-LABEL: f:
17; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
18; CHECK-PREFER-AVX256-NOT: %zmm
19
20define void @f(i32* %a, i32 %n) {
21entry:
22  %cmp4 = icmp sgt i32 %n, 0
23  br i1 %cmp4, label %for.body.preheader, label %for.end
24
25for.body.preheader:                               ; preds = %entry
26  br label %for.body
27
28for.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
36
37for.end.loopexit:                                 ; preds = %for.body
38  br label %for.end
39
40for.end:                                          ; preds = %for.end.loopexit, %entry
41  ret void
42}
43
44; Verify that the "prefer-vector-width=256" attribute prevents the use of 512-bit
45; vectors
46
47; CHECK-LABEL: g:
48; CHECK: vmovdqu %ymm{{.}},
49; CHECK-NOT: %zmm
50
51; CHECK-PREFER-AVX256-LABEL: g:
52; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
53; CHECK-PREFER-AVX256-NOT: %zmm
54
55define void @g(i32* %a, i32 %n) "prefer-vector-width"="256" {
56entry:
57  %cmp4 = icmp sgt i32 %n, 0
58  br i1 %cmp4, label %for.body.preheader, label %for.end
59
60for.body.preheader:                               ; preds = %entry
61  br label %for.body
62
63for.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
71
72for.end.loopexit:                                 ; preds = %for.body
73  br label %for.end
74
75for.end:                                          ; preds = %for.end.loopexit, %entry
76  ret void
77}
78
79; Verify that the "prefer-vector-width=512" attribute override the subtarget
80; vectors
81
82; CHECK-LABEL: h:
83; CHECK: vmovdqu64 %zmm{{.}},
84; CHECK-NOT: %ymm
85
86; CHECK-PREFER-AVX256-LABEL: h:
87; CHECK-PREFER-AVX256: vmovdqu64 %zmm{{.}},
88; CHECK-PREFER-AVX256-NOT: %ymm
89
90define void @h(i32* %a, i32 %n) "prefer-vector-width"="512" {
91entry:
92  %cmp4 = icmp sgt i32 %n, 0
93  br i1 %cmp4, label %for.body.preheader, label %for.end
94
95for.body.preheader:                               ; preds = %entry
96  br label %for.body
97
98for.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
106
107for.end.loopexit:                                 ; preds = %for.body
108  br label %for.end
109
110for.end:                                          ; preds = %for.end.loopexit, %entry
111  ret void
112}
113