1 ; RUN: opt -mtriple=x86_64-unknown-linux-gnu -passes=load-store-vectorizer -S -o - %s | FileCheck %s
2 ; RUN: opt -mtriple=x86_64-unknown-linux-gnu -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' -S -o - %s | FileCheck %s
4 target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
6 %struct.buffer_t = type { i64, ptr }
7 %struct.nested.buffer = type { %struct.buffer_t, %struct.buffer_t }
9 ; Check an i64 and ptr get vectorized, and that the two accesses
10 ; (load into buff.val and store to buff.p) preserve their order.
11 ; Vectorized loads should be inserted at the position of the first load,
12 ; and instructions which were between the first and last load should be
13 ; reordered preserving their relative order inasmuch as possible.
15 ; CHECK-LABEL: @preserve_order_64(
16 ; CHECK: load <2 x i64>
17 ; CHECK: %buff.val = load i8
19 define void @preserve_order_64(ptr noalias %buff) #0 {
21 %tmp1 = getelementptr inbounds %struct.buffer_t, ptr %buff, i64 0, i32 1
22 %buff.p = load ptr, ptr %tmp1
23 %buff.val = load i8, ptr %buff.p
24 store i8 0, ptr %buff.p, align 8
25 %buff.int = load i64, ptr %buff, align 16
29 ; Check reordering recurses correctly.
31 ; CHECK-LABEL: @transitive_reorder(
32 ; CHECK: load <2 x i64>
33 ; CHECK: %buff.val = load i8
35 define void @transitive_reorder(ptr noalias %buff, ptr noalias %nest) #0 {
37 %tmp1 = getelementptr inbounds %struct.buffer_t, ptr %nest, i64 0, i32 1
38 %buff.p = load ptr, ptr %tmp1
39 %buff.val = load i8, ptr %buff.p
40 store i8 0, ptr %buff.p, align 8
41 %buff.int = load i64, ptr %nest, align 16
45 ; Check for no vectorization over phi node
47 ; CHECK-LABEL: @no_vect_phi(
52 define void @no_vect_phi(ptr noalias %ptr, ptr noalias %buff) {
54 %tmp1 = getelementptr inbounds %struct.buffer_t, ptr %buff, i64 0, i32 1
55 %buff.p = load ptr, ptr %tmp1
56 %buff.val = load i8, ptr %buff.p
57 store i8 0, ptr %buff.p, align 8
58 br label %"for something"
61 %index = phi i64 [ 0, %entry ], [ %index.next, %"for something" ]
63 %buff.int = load i64, ptr %buff, align 16
65 %index.next = add i64 %index, 8
66 %cmp_res = icmp eq i64 %index.next, 8
67 br i1 %cmp_res, label %ending, label %"for something"
73 attributes #0 = { nounwind }