]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/LoopVectorize/multiple-strides-vectorization.ll
Vendor import of llvm trunk r321017:
[FreeBSD/FreeBSD.git] / test / Transforms / LoopVectorize / multiple-strides-vectorization.ll
1 ; RUN: opt -loop-vectorize -force-vector-width=4 -S < %s | FileCheck %s
2
3 ; This is the test case from PR26314.
4 ; When we were retrying dependence checking with memchecks only,
5 ; the loop-invariant access in the inner loop was incorrectly determined to be wrapping
6 ; because it was not strided in the inner loop.
7 ; Improved wrapping detection allows vectorization in the following case.
8
9 ; #define Z 32
10 ; typedef struct s {
11 ;       int v1[Z];
12 ;       int v2[Z];
13 ;       int v3[Z][Z];
14 ; } s;
15 ;
16 ; void slow_function (s* const obj, int z) {
17 ;    for (int j=0; j<Z; j++) {
18 ;        for (int k=0; k<z; k++) {
19 ;            int x = obj->v1[k] + obj->v2[j];
20 ;            obj->v3[j][k] += x;
21 ;        }
22 ;    }
23 ; }
24
25 ; CHECK-LABEL: Test
26 ; CHECK: <4 x i64>
27 ; CHECK: <4 x i32>, <4 x i32>
28 ; CHECK: !{!"llvm.loop.isvectorized", i32 1}
29
30 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
31
32 %struct.s = type { [32 x i32], [32 x i32], [32 x [32 x i32]] }
33
34 define void @Test(%struct.s* nocapture %obj, i64 %z) #0 {
35   br label %.outer.preheader
36
37
38 .outer.preheader:
39   %i = phi i64 [ 0, %0 ], [ %i.next, %.outer ]
40   %1 = getelementptr inbounds %struct.s, %struct.s* %obj, i64 0, i32 1, i64 %i
41   br label %.inner
42
43 .exit:
44   ret void
45  
46 .outer:
47   %i.next = add nuw nsw i64 %i, 1
48   %exitcond.outer = icmp eq i64 %i.next, 32
49   br i1 %exitcond.outer, label %.exit, label %.outer.preheader
50
51 .inner:
52   %j = phi i64 [ 0, %.outer.preheader ], [ %j.next, %.inner ]
53   %2 = getelementptr inbounds %struct.s, %struct.s* %obj, i64 0, i32 0, i64 %j
54   %3 = load i32, i32* %2
55   %4 = load i32, i32* %1
56   %5 = add nsw i32 %4, %3
57   %6 = getelementptr inbounds %struct.s, %struct.s* %obj, i64 0, i32 2, i64 %i, i64 %j
58   %7 = load i32, i32* %6
59   %8 = add nsw i32 %5, %7
60   store i32 %8, i32* %6  
61   %j.next = add nuw nsw i64 %j, 1
62   %exitcond.inner = icmp eq i64 %j.next, %z
63   br i1 %exitcond.inner, label %.outer, label %.inner
64 }