2 ; RUN: opt -passes=loop-vectorize -debug-only=loop-accesses -force-vector-width=4 -disable-output %s 2>&1 | FileCheck %s -check-prefix=LOOP-ACCESS
3 ; RUN: opt -passes=loop-vectorize -debug-only=vectorutils -force-vector-width=4 -disable-output %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-redhat-linux-gnu"
7 %struct.foo = type { ptr, ptr, ptr }
8 %struct.pluto = type <{ %struct.wombat, %struct.spam, %struct.wibble, [6 x i8] }>
9 %struct.wombat = type { %struct.barney }
10 %struct.barney = type { %struct.widget }
11 %struct.widget = type { %struct.hoge }
12 %struct.hoge = type { %struct.pluto.0 }
13 %struct.pluto.0 = type { %struct.foo }
14 %struct.spam = type { %struct.barney.1 }
15 %struct.barney.1 = type { %struct.ham }
16 %struct.ham = type { %struct.bar }
17 %struct.bar = type { %struct.barney.2 }
18 %struct.barney.2 = type { %struct.hoge.3 }
19 %struct.hoge.3 = type { ptr, ptr, ptr }
20 %struct.wibble = type { %struct.spam.4 }
21 %struct.spam.4 = type { [2 x %struct.zot] }
22 %struct.zot = type { %struct.bar.5 }
23 %struct.bar.5 = type { i8 }
24 %struct.baz = type { i64, %struct.pluto }
26 ; LOOP-ACCESS: Too many dependences, stopped recording
28 ; If no dependences are recorded because there are too many, LoopAccessAnalysis
29 ; just conservatively returns true for any pair of instructions compared (even
30 ; those belonging to the same store group). This tests make sure that we do not
31 ; incorrectly release a store group which had no dependences between its
32 ; members, even if we have no dependences recorded because there are too many.
34 ; CHECK: LV: Creating an interleave group with: store ptr null, ptr %phi5, align 8
35 ; CHECK: LV: Inserted: store ptr %load12, ptr %getelementptr11, align 8
36 ; CHECK: into the interleave group with store ptr null, ptr %phi5
37 ; CHECK: LV: Inserted: store ptr %load7, ptr %getelementptr, align 8
38 ; CHECK: into the interleave group with store ptr null, ptr %phi5
40 ; CHECK: LV: Creating an interleave group with: store ptr null, ptr %getelementptr13, align 8
41 ; CHECK: LV: Inserted: store ptr null, ptr %phi6, align 8
42 ; CHECK: into the interleave group with store ptr null, ptr %getelementptr13
43 ; CHECK: LV: Invalidated store group due to dependence between store ptr %load7, ptr %getelementptr, align 8 and store ptr null, ptr %getelementptr13, align 8
44 ; CHECK-NOT: LV: Invalidated store group due to dependence between
46 ; Note: The (only) invalidated store group is the one containing A (store ptr %load7, ptr %getelementptr, align 8) which is:
47 ; Group with instructions:
48 ; store ptr null, ptr %phi5, align 8
49 ; store ptr %load7, ptr %getelementptr, align 8
50 ; store ptr %load12, ptr %getelementptr11, align 8
51 define void @test(ptr %arg, ptr %arg1) local_unnamed_addr #0 {
55 bb2: ; preds = %bb4, %bb
56 %phi = phi ptr [ %arg, %bb ], [ %phi3, %bb4 ]
57 %phi3 = phi ptr [ %arg1, %bb ], [ null, %bb4 ]
60 bb4: ; preds = %bb4, %bb2
61 %phi5 = phi ptr [ %getelementptr15, %bb4 ], [ %phi, %bb2 ]
62 %phi6 = phi ptr [ %getelementptr14, %bb4 ], [ %phi3, %bb2 ]
63 %load = load i64, ptr %phi5, align 8
64 store i64 %load, ptr %phi, align 8
65 store i64 0, ptr %phi3, align 8
66 %load7 = load ptr, ptr %phi6, align 8
67 %load8 = load ptr, ptr %phi5, align 8
68 store ptr %load8, ptr %phi6, align 8
69 %getelementptr = getelementptr %struct.foo, ptr %phi5, i64 0, i32 1
70 %load9 = load ptr, ptr %phi5, align 8
71 store ptr %load9, ptr %phi6, align 8
72 %load10 = load ptr, ptr %phi5, align 8
73 store ptr %load10, ptr %phi6, align 8
74 store ptr null, ptr %phi5, align 8
75 store ptr %load7, ptr %getelementptr, align 8
76 %getelementptr11 = getelementptr %struct.pluto, ptr %phi5, i64 0, i32 1
77 %load12 = load ptr, ptr %phi6, align 8
78 %getelementptr13 = getelementptr %struct.pluto, ptr %phi6, i64 0, i32 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 2
79 store ptr null, ptr %phi6, align 8
80 store ptr null, ptr %getelementptr13, align 8
81 store ptr %load12, ptr %getelementptr11, align 8
82 store ptr null, ptr %phi5, align 8
83 %getelementptr14 = getelementptr inbounds %struct.baz, ptr %phi6, i64 1
84 %getelementptr15 = getelementptr %struct.baz, ptr %phi5, i64 1
85 %icmp = icmp eq ptr %phi6, %phi
86 br i1 %icmp, label %bb2, label %bb4
89 ; Function Attrs: memory(readwrite, inaccessiblemem: none)
90 declare void @foo() local_unnamed_addr #0
92 ; Function Attrs: memory(argmem: readwrite)
93 declare void @pluto() local_unnamed_addr #1
95 attributes #0 = { memory(readwrite, inaccessiblemem: none) }
96 attributes #1 = { memory(argmem: readwrite) }