diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:17:04 +0000 |
| commit | b915e9e0fc85ba6f398b3fab0db6a81a8913af94 (patch) | |
| tree | 98b8f811c7aff2547cab8642daf372d6c59502fb /test/Transforms/LoadStoreVectorizer | |
| parent | 6421cca32f69ac849537a3cff78c352195e99f1b (diff) | |
Notes
Diffstat (limited to 'test/Transforms/LoadStoreVectorizer')
15 files changed, 648 insertions, 66 deletions
diff --git a/test/Transforms/LoadStoreVectorizer/AMDGPU/adjust-alloca-alignment.ll b/test/Transforms/LoadStoreVectorizer/AMDGPU/adjust-alloca-alignment.ll new file mode 100644 index 000000000000..4369dafa4258 --- /dev/null +++ b/test/Transforms/LoadStoreVectorizer/AMDGPU/adjust-alloca-alignment.ll @@ -0,0 +1,129 @@ +; RUN: opt -S -load-store-vectorizer -mattr=-unaligned-buffer-access,+max-private-element-size-16 < %s | FileCheck -check-prefix=ALIGNED -check-prefix=ALL %s +; RUN: opt -S -load-store-vectorizer -mattr=+unaligned-buffer-access,+unaligned-scratch-access,+max-private-element-size-16 < %s | FileCheck -check-prefix=UNALIGNED -check-prefix=ALL %s + +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" +target triple = "amdgcn--" + +; ALL-LABEL: @load_unknown_offset_align1_i8( +; ALL: alloca [128 x i8], align 1 +; UNALIGNED: load <2 x i8>, <2 x i8>* %{{[0-9]+}}, align 1{{$}} + +; ALIGNED: load i8, i8* %ptr0, align 1{{$}} +; ALIGNED: load i8, i8* %ptr1, align 1{{$}} +define void @load_unknown_offset_align1_i8(i8 addrspace(1)* noalias %out, i32 %offset) #0 { + %alloca = alloca [128 x i8], align 1 + %ptr0 = getelementptr inbounds [128 x i8], [128 x i8]* %alloca, i32 0, i32 %offset + %val0 = load i8, i8* %ptr0, align 1 + %ptr1 = getelementptr inbounds i8, i8* %ptr0, i32 1 + %val1 = load i8, i8* %ptr1, align 1 + %add = add i8 %val0, %val1 + store i8 %add, i8 addrspace(1)* %out + ret void +} + +; ALL-LABEL: @load_unknown_offset_align1_i16( +; ALL: alloca [128 x i16], align 1{{$}} +; UNALIGNED: load <2 x i16>, <2 x i16>* %{{[0-9]+}}, align 1{{$}} + +; ALIGNED: load i16, i16* %ptr0, align 1{{$}} +; ALIGNED: load i16, i16* %ptr1, align 1{{$}} +define void @load_unknown_offset_align1_i16(i16 addrspace(1)* noalias %out, i32 %offset) #0 { + %alloca = alloca [128 x i16], align 1 + %ptr0 = getelementptr inbounds [128 x i16], [128 x i16]* %alloca, i32 0, i32 %offset + %val0 = load i16, i16* %ptr0, align 1 + %ptr1 = getelementptr inbounds i16, i16* %ptr0, i32 1 + %val1 = load i16, i16* %ptr1, align 1 + %add = add i16 %val0, %val1 + store i16 %add, i16 addrspace(1)* %out + ret void +} + +; FIXME: Although the offset is unknown here, we know it is a multiple +; of the element size, so should still be align 4 + +; ALL-LABEL: @load_unknown_offset_align1_i32( +; ALL: alloca [128 x i32], align 1 +; UNALIGNED: load <2 x i32>, <2 x i32>* %{{[0-9]+}}, align 1{{$}} + +; ALIGNED: load i32, i32* %ptr0, align 1 +; ALIGNED: load i32, i32* %ptr1, align 1 +define void @load_unknown_offset_align1_i32(i32 addrspace(1)* noalias %out, i32 %offset) #0 { + %alloca = alloca [128 x i32], align 1 + %ptr0 = getelementptr inbounds [128 x i32], [128 x i32]* %alloca, i32 0, i32 %offset + %val0 = load i32, i32* %ptr0, align 1 + %ptr1 = getelementptr inbounds i32, i32* %ptr0, i32 1 + %val1 = load i32, i32* %ptr1, align 1 + %add = add i32 %val0, %val1 + store i32 %add, i32 addrspace(1)* %out + ret void +} + +; FIXME: Should always increase alignment of the load +; Make sure alloca alignment isn't decreased +; ALL-LABEL: @load_alloca16_unknown_offset_align1_i32( +; ALL: alloca [128 x i32], align 16 + +; UNALIGNED: load <2 x i32>, <2 x i32>* %{{[0-9]+}}, align 1{{$}} +; ALIGNED: load <2 x i32>, <2 x i32>* %{{[0-9]+}}, align 4{{$}} +define void @load_alloca16_unknown_offset_align1_i32(i32 addrspace(1)* noalias %out, i32 %offset) #0 { + %alloca = alloca [128 x i32], align 16 + %ptr0 = getelementptr inbounds [128 x i32], [128 x i32]* %alloca, i32 0, i32 %offset + %val0 = load i32, i32* %ptr0, align 1 + %ptr1 = getelementptr inbounds i32, i32* %ptr0, i32 1 + %val1 = load i32, i32* %ptr1, align 1 + %add = add i32 %val0, %val1 + store i32 %add, i32 addrspace(1)* %out + ret void +} + +; ALL-LABEL: @store_unknown_offset_align1_i8( +; ALL: alloca [128 x i8], align 1 +; UNALIGNED: store <2 x i8> <i8 9, i8 10>, <2 x i8>* %{{[0-9]+}}, align 1{{$}} + +; ALIGNED: store i8 9, i8* %ptr0, align 1{{$}} +; ALIGNED: store i8 10, i8* %ptr1, align 1{{$}} +define void @store_unknown_offset_align1_i8(i8 addrspace(1)* noalias %out, i32 %offset) #0 { + %alloca = alloca [128 x i8], align 1 + %ptr0 = getelementptr inbounds [128 x i8], [128 x i8]* %alloca, i32 0, i32 %offset + store i8 9, i8* %ptr0, align 1 + %ptr1 = getelementptr inbounds i8, i8* %ptr0, i32 1 + store i8 10, i8* %ptr1, align 1 + ret void +} + +; ALL-LABEL: @store_unknown_offset_align1_i16( +; ALL: alloca [128 x i16], align 1 +; UNALIGNED: store <2 x i16> <i16 9, i16 10>, <2 x i16>* %{{[0-9]+}}, align 1{{$}} + +; ALIGNED: store i16 9, i16* %ptr0, align 1{{$}} +; ALIGNED: store i16 10, i16* %ptr1, align 1{{$}} +define void @store_unknown_offset_align1_i16(i16 addrspace(1)* noalias %out, i32 %offset) #0 { + %alloca = alloca [128 x i16], align 1 + %ptr0 = getelementptr inbounds [128 x i16], [128 x i16]* %alloca, i32 0, i32 %offset + store i16 9, i16* %ptr0, align 1 + %ptr1 = getelementptr inbounds i16, i16* %ptr0, i32 1 + store i16 10, i16* %ptr1, align 1 + ret void +} + +; FIXME: Although the offset is unknown here, we know it is a multiple +; of the element size, so it still should be align 4. + +; ALL-LABEL: @store_unknown_offset_align1_i32( +; ALL: alloca [128 x i32], align 1 + +; UNALIGNED: store <2 x i32> <i32 9, i32 10>, <2 x i32>* %{{[0-9]+}}, align 1{{$}} + +; ALIGNED: store i32 9, i32* %ptr0, align 1 +; ALIGNED: store i32 10, i32* %ptr1, align 1 +define void @store_unknown_offset_align1_i32(i32 addrspace(1)* noalias %out, i32 %offset) #0 { + %alloca = alloca [128 x i32], align 1 + %ptr0 = getelementptr inbounds [128 x i32], [128 x i32]* %alloca, i32 0, i32 %offset + store i32 9, i32* %ptr0, align 1 + %ptr1 = getelementptr inbounds i32, i32* %ptr0, i32 1 + store i32 10, i32* %ptr1, align 1 + ret void +} + +attributes #0 = { nounwind } + diff --git a/test/Transforms/LoadStoreVectorizer/AMDGPU/insertion-point.ll b/test/Transforms/LoadStoreVectorizer/AMDGPU/insertion-point.ll index 64a0480d8d3c..2b2f9cbcf508 100644 --- a/test/Transforms/LoadStoreVectorizer/AMDGPU/insertion-point.ll +++ b/test/Transforms/LoadStoreVectorizer/AMDGPU/insertion-point.ll @@ -2,8 +2,9 @@ target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" -; Check relative position of the inserted vector load relative to the existing -; adds. Vectorized loads should be inserted at the position of the first load. +; Check position of the inserted vector load/store. Vectorized loads should be +; inserted at the position of the first load in the chain, and stores should be +; inserted at the position of the last store. ; CHECK-LABEL: @insert_load_point( ; CHECK: %z = add i32 %x, 4 @@ -59,4 +60,58 @@ entry: ret void } +; Here we have four stores, with an aliasing load before the last one. We can +; vectorize the first three stores as <3 x float>, but this vectorized store must +; be inserted at the location of the third scalar store, not the fourth one. +; +; CHECK-LABEL: @insert_store_point_alias +; CHECK: store <3 x float> +; CHECK: load float, float addrspace(1)* %a.idx.2 +; CHECK: store float +; CHECK-SAME: %a.idx.3 +define float @insert_store_point_alias(float addrspace(1)* nocapture %a, i64 %idx) { + %a.idx = getelementptr inbounds float, float addrspace(1)* %a, i64 %idx + %a.idx.1 = getelementptr inbounds float, float addrspace(1)* %a.idx, i64 1 + %a.idx.2 = getelementptr inbounds float, float addrspace(1)* %a.idx.1, i64 1 + %a.idx.3 = getelementptr inbounds float, float addrspace(1)* %a.idx.2, i64 1 + + store float 0.0, float addrspace(1)* %a.idx, align 4 + store float 0.0, float addrspace(1)* %a.idx.1, align 4 + store float 0.0, float addrspace(1)* %a.idx.2, align 4 + %x = load float, float addrspace(1)* %a.idx.2, align 4 + store float 0.0, float addrspace(1)* %a.idx.3, align 4 + + ret float %x +} + +; Here we have four stores, with an aliasing load before the last one. We +; could vectorize two of the stores before the load (although we currently +; don't), but the important thing is that we *don't* sink the store to +; a[idx + 1] below the load. +; +; CHECK-LABEL: @insert_store_point_alias_ooo +; CHECK: store float +; CHECK-SAME: %a.idx.3 +; CHECK: store float +; CHECK-SAME: %a.idx.1 +; CHECK: store float +; CHECK-SAME: %a.idx.2 +; CHECK: load float, float addrspace(1)* %a.idx.2 +; CHECK: store float +; CHECK-SAME: %a.idx +define float @insert_store_point_alias_ooo(float addrspace(1)* nocapture %a, i64 %idx) { + %a.idx = getelementptr inbounds float, float addrspace(1)* %a, i64 %idx + %a.idx.1 = getelementptr inbounds float, float addrspace(1)* %a.idx, i64 1 + %a.idx.2 = getelementptr inbounds float, float addrspace(1)* %a.idx.1, i64 1 + %a.idx.3 = getelementptr inbounds float, float addrspace(1)* %a.idx.2, i64 1 + + store float 0.0, float addrspace(1)* %a.idx.3, align 4 + store float 0.0, float addrspace(1)* %a.idx.1, align 4 + store float 0.0, float addrspace(1)* %a.idx.2, align 4 + %x = load float, float addrspace(1)* %a.idx.2, align 4 + store float 0.0, float addrspace(1)* %a.idx, align 4 + + ret float %x +} + attributes #0 = { nounwind } diff --git a/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores-private.ll b/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores-private.ll index 4a4237294294..fd0aaa615db0 100644 --- a/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores-private.ll +++ b/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores-private.ll @@ -1,19 +1,21 @@ -; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-4 -load-store-vectorizer -S -o - %s | FileCheck -check-prefix=ELT4 -check-prefix=ALL %s -; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-8 -load-store-vectorizer -S -o - %s | FileCheck -check-prefix=ELT8 -check-prefix=ALL %s -; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-16 -load-store-vectorizer -S -o - %s | FileCheck -check-prefix=ELT16 -check-prefix=ALL %s +; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-4 -load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT4,ALIGNED,ALL %s +; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-8 -load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT8,ALIGNED,ALL %s +; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-8,+unaligned-scratch-access -load-store-vectorizer -S -o - %s | FileCheck -check-prefix=ELT8-UNALIGNED -check-prefix=ALL %s +; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-16 -load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT16,ALIGNED,ALL %s +; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-16,+unaligned-scratch-access -load-store-vectorizer -S -o - %s | FileCheck -check-prefix=ELT16-UNALIGNED -check-prefix=ALL %s target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v4i32 -; ELT4: store i32 -; ELT4: store i32 -; ELT4: store i32 -; ELT4: store i32 +; ALIGNED: store i32 +; ALIGNED: store i32 +; ALIGNED: store i32 +; ALIGNED: store i32 -; ELT8: store <2 x i32> -; ELT8: store <2 x i32> +; ELT8-UNALIGNED: store <2 x i32> +; ELT8-UNALIGNED: store <2 x i32> -; ELT16: store <4 x i32> +; ELT16-UNALIGNED: store <4 x i32> define void @merge_private_store_4_vector_elts_loads_v4i32(i32* %out) #0 { %out.gep.1 = getelementptr i32, i32* %out, i32 1 %out.gep.2 = getelementptr i32, i32* %out, i32 2 diff --git a/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores.ll b/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores.ll index 03265efe2843..d32387fa2c06 100644 --- a/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores.ll +++ b/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-stores.ll @@ -196,11 +196,11 @@ define void @merge_global_store_4_constants_i64(i64 addrspace(1)* %out) #0 { } ; CHECK-LABEL: @merge_global_store_2_adjacent_loads_i32 -; CHECK: [[LOAD:%[0-9]+]] = load <2 x i32> -; CHECK: [[ELT0:%[0-9]+]] = extractelement <2 x i32> [[LOAD]], i32 0 -; CHECK: [[ELT1:%[0-9]+]] = extractelement <2 x i32> [[LOAD]], i32 1 -; CHECK: [[INSERT0:%[0-9]+]] = insertelement <2 x i32> undef, i32 [[ELT0]], i32 0 -; CHECK: [[INSERT1:%[0-9]+]] = insertelement <2 x i32> [[INSERT0]], i32 [[ELT1]], i32 1 +; CHECK: [[LOAD:%[^ ]+]] = load <2 x i32> +; CHECK: [[ELT0:%[^ ]+]] = extractelement <2 x i32> [[LOAD]], i32 0 +; CHECK: [[ELT1:%[^ ]+]] = extractelement <2 x i32> [[LOAD]], i32 1 +; CHECK: [[INSERT0:%[^ ]+]] = insertelement <2 x i32> undef, i32 [[ELT0]], i32 0 +; CHECK: [[INSERT1:%[^ ]+]] = insertelement <2 x i32> [[INSERT0]], i32 [[ELT1]], i32 1 ; CHECK: store <2 x i32> [[INSERT1]] define void @merge_global_store_2_adjacent_loads_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 { %out.gep.1 = getelementptr i32, i32 addrspace(1)* %out, i32 1 @@ -235,11 +235,11 @@ define void @merge_global_store_2_adjacent_loads_i32_nonzero_base(i32 addrspace( } ; CHECK-LABEL: @merge_global_store_2_adjacent_loads_shuffle_i32 -; CHECK: [[LOAD:%[0-9]+]] = load <2 x i32> -; CHECK: [[ELT0:%[0-9]+]] = extractelement <2 x i32> [[LOAD]], i32 0 -; CHECK: [[ELT1:%[0-9]+]] = extractelement <2 x i32> [[LOAD]], i32 1 -; CHECK: [[INSERT0:%[0-9]+]] = insertelement <2 x i32> undef, i32 [[ELT1]], i32 0 -; CHECK: [[INSERT1:%[0-9]+]] = insertelement <2 x i32> [[INSERT0]], i32 [[ELT0]], i32 1 +; CHECK: [[LOAD:%[^ ]+]] = load <2 x i32> +; CHECK: [[ELT0:%[^ ]+]] = extractelement <2 x i32> [[LOAD]], i32 0 +; CHECK: [[ELT1:%[^ ]+]] = extractelement <2 x i32> [[LOAD]], i32 1 +; CHECK: [[INSERT0:%[^ ]+]] = insertelement <2 x i32> undef, i32 [[ELT1]], i32 0 +; CHECK: [[INSERT1:%[^ ]+]] = insertelement <2 x i32> [[INSERT0]], i32 [[ELT0]], i32 1 ; CHECK: store <2 x i32> [[INSERT1]] define void @merge_global_store_2_adjacent_loads_shuffle_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 { %out.gep.1 = getelementptr i32, i32 addrspace(1)* %out, i32 1 diff --git a/test/Transforms/LoadStoreVectorizer/AMDGPU/multiple_tails.ll b/test/Transforms/LoadStoreVectorizer/AMDGPU/multiple_tails.ll new file mode 100644 index 000000000000..88eca363902f --- /dev/null +++ b/test/Transforms/LoadStoreVectorizer/AMDGPU/multiple_tails.ll @@ -0,0 +1,64 @@ +; RUN: opt -mtriple=amdgcn-amd-amdhsa -basicaa -load-store-vectorizer -S -o - %s | FileCheck %s + +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + +; Checks that there is no crash when there are multiple tails +; for a the same head starting a chain. +@0 = internal addrspace(3) global [16384 x i32] undef + +; CHECK-LABEL: @no_crash( +; CHECK: store <2 x i32> zeroinitializer +; CHECK: store i32 0 +; CHECK: store i32 0 + +define void @no_crash(i32 %arg) { + %tmp2 = add i32 %arg, 14 + %tmp3 = getelementptr [16384 x i32], [16384 x i32] addrspace(3)* @0, i32 0, i32 %tmp2 + %tmp4 = add i32 %arg, 15 + %tmp5 = getelementptr [16384 x i32], [16384 x i32] addrspace(3)* @0, i32 0, i32 %tmp4 + + store i32 0, i32 addrspace(3)* %tmp3, align 4 + store i32 0, i32 addrspace(3)* %tmp5, align 4 + store i32 0, i32 addrspace(3)* %tmp5, align 4 + store i32 0, i32 addrspace(3)* %tmp5, align 4 + + ret void +} + +; Check adjiacent memory locations are properly matched and the +; longest chain vectorized + +; CHECK-LABEL: @interleave_get_longest +; CHECK: load <2 x i32> +; CHECK: load i32 +; CHECK: store <2 x i32> zeroinitializer +; CHECK: load i32 +; CHECK: load <2 x i32> +; CHECK: load i32 +; CHECK: load i32 + +define void @interleave_get_longest(i32 %arg) { + %a1 = add i32 %arg, 1 + %a2 = add i32 %arg, 2 + %a3 = add i32 %arg, 3 + %a4 = add i32 %arg, 4 + %tmp1 = getelementptr [16384 x i32], [16384 x i32] addrspace(3)* @0, i32 0, i32 %arg + %tmp2 = getelementptr [16384 x i32], [16384 x i32] addrspace(3)* @0, i32 0, i32 %a1 + %tmp3 = getelementptr [16384 x i32], [16384 x i32] addrspace(3)* @0, i32 0, i32 %a2 + %tmp4 = getelementptr [16384 x i32], [16384 x i32] addrspace(3)* @0, i32 0, i32 %a3 + %tmp5 = getelementptr [16384 x i32], [16384 x i32] addrspace(3)* @0, i32 0, i32 %a4 + + %l1 = load i32, i32 addrspace(3)* %tmp2, align 4 + %l2 = load i32, i32 addrspace(3)* %tmp1, align 4 + store i32 0, i32 addrspace(3)* %tmp2, align 4 + store i32 0, i32 addrspace(3)* %tmp1, align 4 + %l3 = load i32, i32 addrspace(3)* %tmp2, align 4 + %l4 = load i32, i32 addrspace(3)* %tmp3, align 4 + %l5 = load i32, i32 addrspace(3)* %tmp4, align 4 + %l6 = load i32, i32 addrspace(3)* %tmp5, align 4 + %l7 = load i32, i32 addrspace(3)* %tmp5, align 4 + %l8 = load i32, i32 addrspace(3)* %tmp5, align 4 + + ret void +} + diff --git a/test/Transforms/LoadStoreVectorizer/AMDGPU/pointer-elements.ll b/test/Transforms/LoadStoreVectorizer/AMDGPU/pointer-elements.ll index 9b73f34ec6cf..202e988ea5f1 100644 --- a/test/Transforms/LoadStoreVectorizer/AMDGPU/pointer-elements.ll +++ b/test/Transforms/LoadStoreVectorizer/AMDGPU/pointer-elements.ll @@ -6,8 +6,8 @@ declare i32 @llvm.amdgcn.workitem.id.x() #1 ; CHECK-LABEL: @merge_v2p1i8( ; CHECK: load <2 x i64> -; CHECK: inttoptr i64 %{{[0-9]+}} to i8 addrspace(1)* -; CHECK: inttoptr i64 %{{[0-9]+}} to i8 addrspace(1)* +; CHECK: inttoptr i64 %{{[^ ]+}} to i8 addrspace(1)* +; CHECK: inttoptr i64 %{{[^ ]+}} to i8 addrspace(1)* ; CHECK: store <2 x i64> zeroinitializer define void @merge_v2p1i8(i8 addrspace(1)* addrspace(1)* nocapture %a, i8 addrspace(1)* addrspace(1)* nocapture readonly %b) #0 { entry: @@ -25,8 +25,8 @@ entry: ; CHECK-LABEL: @merge_v2p3i8( ; CHECK: load <2 x i32> -; CHECK: inttoptr i32 %{{[0-9]+}} to i8 addrspace(3)* -; CHECK: inttoptr i32 %{{[0-9]+}} to i8 addrspace(3)* +; CHECK: inttoptr i32 %{{[^ ]+}} to i8 addrspace(3)* +; CHECK: inttoptr i32 %{{[^ ]+}} to i8 addrspace(3)* ; CHECK: store <2 x i32> zeroinitializer define void @merge_v2p3i8(i8 addrspace(3)* addrspace(3)* nocapture %a, i8 addrspace(3)* addrspace(3)* nocapture readonly %b) #0 { entry: @@ -44,7 +44,7 @@ entry: ; CHECK-LABEL: @merge_load_i64_ptr64( ; CHECK: load <2 x i64> -; CHECK: [[ELT1:%[0-9]+]] = extractelement <2 x i64> %{{[0-9]+}}, i32 1 +; CHECK: [[ELT1:%[^ ]+]] = extractelement <2 x i64> %{{[^ ]+}}, i32 1 ; CHECK: inttoptr i64 [[ELT1]] to i8 addrspace(1)* define void @merge_load_i64_ptr64(i64 addrspace(1)* nocapture %a) #0 { entry: @@ -59,7 +59,7 @@ entry: ; CHECK-LABEL: @merge_load_ptr64_i64( ; CHECK: load <2 x i64> -; CHECK: [[ELT0:%[0-9]+]] = extractelement <2 x i64> %{{[0-9]+}}, i32 0 +; CHECK: [[ELT0:%[^ ]+]] = extractelement <2 x i64> %{{[^ ]+}}, i32 0 ; CHECK: inttoptr i64 [[ELT0]] to i8 addrspace(1)* define void @merge_load_ptr64_i64(i64 addrspace(1)* nocapture %a) #0 { entry: @@ -73,7 +73,7 @@ entry: } ; CHECK-LABEL: @merge_store_ptr64_i64( -; CHECK: [[ELT0:%[0-9]+]] = ptrtoint i8 addrspace(1)* %ptr0 to i64 +; CHECK: [[ELT0:%[^ ]+]] = ptrtoint i8 addrspace(1)* %ptr0 to i64 ; CHECK: insertelement <2 x i64> undef, i64 [[ELT0]], i32 0 ; CHECK: store <2 x i64> define void @merge_store_ptr64_i64(i64 addrspace(1)* nocapture %a, i8 addrspace(1)* %ptr0, i64 %val1) #0 { @@ -89,8 +89,8 @@ entry: } ; CHECK-LABEL: @merge_store_i64_ptr64( -; CHECK: [[ELT1:%[0-9]+]] = ptrtoint i8 addrspace(1)* %ptr1 to i64 -; CHECK: insertelement <2 x i64> %{{[0-9]+}}, i64 [[ELT1]], i32 1 +; CHECK: [[ELT1:%[^ ]+]] = ptrtoint i8 addrspace(1)* %ptr1 to i64 +; CHECK: insertelement <2 x i64> %{{[^ ]+}}, i64 [[ELT1]], i32 1 ; CHECK: store <2 x i64> define void @merge_store_i64_ptr64(i8 addrspace(1)* addrspace(1)* nocapture %a, i64 %val0, i8 addrspace(1)* %ptr1) #0 { entry: @@ -105,7 +105,7 @@ entry: ; CHECK-LABEL: @merge_load_i32_ptr32( ; CHECK: load <2 x i32> -; CHECK: [[ELT1:%[0-9]+]] = extractelement <2 x i32> %{{[0-9]+}}, i32 1 +; CHECK: [[ELT1:%[^ ]+]] = extractelement <2 x i32> %{{[^ ]+}}, i32 1 ; CHECK: inttoptr i32 [[ELT1]] to i8 addrspace(3)* define void @merge_load_i32_ptr32(i32 addrspace(3)* nocapture %a) #0 { entry: @@ -120,7 +120,7 @@ entry: ; CHECK-LABEL: @merge_load_ptr32_i32( ; CHECK: load <2 x i32> -; CHECK: [[ELT0:%[0-9]+]] = extractelement <2 x i32> %{{[0-9]+}}, i32 0 +; CHECK: [[ELT0:%[^ ]+]] = extractelement <2 x i32> %{{[^ ]+}}, i32 0 ; CHECK: inttoptr i32 [[ELT0]] to i8 addrspace(3)* define void @merge_load_ptr32_i32(i32 addrspace(3)* nocapture %a) #0 { entry: @@ -134,7 +134,7 @@ entry: } ; CHECK-LABEL: @merge_store_ptr32_i32( -; CHECK: [[ELT0:%[0-9]+]] = ptrtoint i8 addrspace(3)* %ptr0 to i32 +; CHECK: [[ELT0:%[^ ]+]] = ptrtoint i8 addrspace(3)* %ptr0 to i32 ; CHECK: insertelement <2 x i32> undef, i32 [[ELT0]], i32 0 ; CHECK: store <2 x i32> define void @merge_store_ptr32_i32(i32 addrspace(3)* nocapture %a, i8 addrspace(3)* %ptr0, i32 %val1) #0 { @@ -149,8 +149,8 @@ entry: } ; CHECK-LABEL: @merge_store_i32_ptr32( -; CHECK: [[ELT1:%[0-9]+]] = ptrtoint i8 addrspace(3)* %ptr1 to i32 -; CHECK: insertelement <2 x i32> %{{[0-9]+}}, i32 [[ELT1]], i32 1 +; CHECK: [[ELT1:%[^ ]+]] = ptrtoint i8 addrspace(3)* %ptr1 to i32 +; CHECK: insertelement <2 x i32> %{{[^ ]+}}, i32 [[ELT1]], i32 1 ; CHECK: store <2 x i32> define void @merge_store_i32_ptr32(i8 addrspace(3)* addrspace(3)* nocapture %a, i32 %val0, i8 addrspace(3)* %ptr1) #0 { entry: @@ -241,9 +241,9 @@ entry: ; CHECK-LABEL: @merge_load_ptr64_f64( ; CHECK: load <2 x i64> -; CHECK: [[ELT0:%[0-9]+]] = extractelement <2 x i64> %{{[0-9]+}}, i32 0 -; CHECK: [[ELT0_INT:%[0-9]+]] = inttoptr i64 [[ELT0]] to i8 addrspace(1)* -; CHECK: [[ELT1_INT:%[0-9]+]] = extractelement <2 x i64> %{{[0-9]+}}, i32 1 +; CHECK: [[ELT0:%[^ ]+]] = extractelement <2 x i64> %{{[^ ]+}}, i32 0 +; CHECK: [[ELT0_INT:%[^ ]+]] = inttoptr i64 [[ELT0]] to i8 addrspace(1)* +; CHECK: [[ELT1_INT:%[^ ]+]] = extractelement <2 x i64> %{{[^ ]+}}, i32 1 ; CHECK: bitcast i64 [[ELT1_INT]] to double define void @merge_load_ptr64_f64(double addrspace(1)* nocapture %a) #0 { entry: @@ -258,9 +258,9 @@ entry: ; CHECK-LABEL: @merge_load_f64_ptr64( ; CHECK: load <2 x i64> -; CHECK: [[ELT0:%[0-9]+]] = extractelement <2 x i64> %{{[0-9]+}}, i32 0 +; CHECK: [[ELT0:%[^ ]+]] = extractelement <2 x i64> %{{[^ ]+}}, i32 0 ; CHECK: bitcast i64 [[ELT0]] to double -; CHECK: [[ELT1:%[0-9]+]] = extractelement <2 x i64> %{{[0-9]+}}, i32 1 +; CHECK: [[ELT1:%[^ ]+]] = extractelement <2 x i64> %{{[^ ]+}}, i32 1 ; CHECK: inttoptr i64 [[ELT1]] to i8 addrspace(1)* define void @merge_load_f64_ptr64(double addrspace(1)* nocapture %a) #0 { entry: @@ -274,10 +274,10 @@ entry: } ; CHECK-LABEL: @merge_store_ptr64_f64( -; CHECK: [[ELT0_INT:%[0-9]+]] = ptrtoint i8 addrspace(1)* %ptr0 to i64 +; CHECK: [[ELT0_INT:%[^ ]+]] = ptrtoint i8 addrspace(1)* %ptr0 to i64 ; CHECK: insertelement <2 x i64> undef, i64 [[ELT0_INT]], i32 0 -; CHECK: [[ELT1_INT:%[0-9]+]] = bitcast double %val1 to i64 -; CHECK: insertelement <2 x i64> %{{[0-9]+}}, i64 [[ELT1_INT]], i32 1 +; CHECK: [[ELT1_INT:%[^ ]+]] = bitcast double %val1 to i64 +; CHECK: insertelement <2 x i64> %{{[^ ]+}}, i64 [[ELT1_INT]], i32 1 ; CHECK: store <2 x i64> define void @merge_store_ptr64_f64(double addrspace(1)* nocapture %a, i8 addrspace(1)* %ptr0, double %val1) #0 { entry: @@ -291,10 +291,10 @@ entry: } ; CHECK-LABEL: @merge_store_f64_ptr64( -; CHECK: [[ELT0_INT:%[0-9]+]] = bitcast double %val0 to i64 +; CHECK: [[ELT0_INT:%[^ ]+]] = bitcast double %val0 to i64 ; CHECK: insertelement <2 x i64> undef, i64 [[ELT0_INT]], i32 0 -; CHECK: [[ELT1_INT:%[0-9]+]] = ptrtoint i8 addrspace(1)* %ptr1 to i64 -; CHECK: insertelement <2 x i64> %{{[0-9]+}}, i64 [[ELT1_INT]], i32 1 +; CHECK: [[ELT1_INT:%[^ ]+]] = ptrtoint i8 addrspace(1)* %ptr1 to i64 +; CHECK: insertelement <2 x i64> %{{[^ ]+}}, i64 [[ELT1_INT]], i32 1 ; CHECK: store <2 x i64> define void @merge_store_f64_ptr64(i8 addrspace(1)* addrspace(1)* nocapture %a, double %val0, i8 addrspace(1)* %ptr1) #0 { entry: diff --git a/test/Transforms/LoadStoreVectorizer/AMDGPU/store_with_aliasing_load.ll b/test/Transforms/LoadStoreVectorizer/AMDGPU/store_with_aliasing_load.ll new file mode 100644 index 000000000000..d70c449e14d7 --- /dev/null +++ b/test/Transforms/LoadStoreVectorizer/AMDGPU/store_with_aliasing_load.ll @@ -0,0 +1,58 @@ +; RUN: opt -mtriple=amdgcn-amd-amdhsa -load-store-vectorizer -S -o - %s | FileCheck %s + +; Check that, in the presence of an aliasing load, the stores preceding the +; aliasing load are safe to vectorize. + +; CHECK-LABEL: store_vectorize_with_alias +; CHECK: store <4 x float> +; CHECK: load <4 x float> +; CHECK: store <4 x float> + +; Function Attrs: nounwind +define void @store_vectorize_with_alias(i8 addrspace(1)* %a, i8 addrspace(1)* %b) #0 { +bb: + %tmp = bitcast i8 addrspace(1)* %b to float addrspace(1)* + %tmp1 = load float, float addrspace(1)* %tmp, align 4 + + %tmp2 = bitcast i8 addrspace(1)* %a to float addrspace(1)* + store float %tmp1, float addrspace(1)* %tmp2, align 4 + %tmp3 = getelementptr i8, i8 addrspace(1)* %a, i64 4 + %tmp4 = bitcast i8 addrspace(1)* %tmp3 to float addrspace(1)* + store float %tmp1, float addrspace(1)* %tmp4, align 4 + %tmp5 = getelementptr i8, i8 addrspace(1)* %a, i64 8 + %tmp6 = bitcast i8 addrspace(1)* %tmp5 to float addrspace(1)* + store float %tmp1, float addrspace(1)* %tmp6, align 4 + %tmp7 = getelementptr i8, i8 addrspace(1)* %a, i64 12 + %tmp8 = bitcast i8 addrspace(1)* %tmp7 to float addrspace(1)* + store float %tmp1, float addrspace(1)* %tmp8, align 4 + + %tmp9 = getelementptr i8, i8 addrspace(1)* %b, i64 16 + %tmp10 = bitcast i8 addrspace(1)* %tmp9 to float addrspace(1)* + %tmp11 = load float, float addrspace(1)* %tmp10, align 4 + %tmp12 = getelementptr i8, i8 addrspace(1)* %b, i64 20 + %tmp13 = bitcast i8 addrspace(1)* %tmp12 to float addrspace(1)* + %tmp14 = load float, float addrspace(1)* %tmp13, align 4 + %tmp15 = getelementptr i8, i8 addrspace(1)* %b, i64 24 + %tmp16 = bitcast i8 addrspace(1)* %tmp15 to float addrspace(1)* + %tmp17 = load float, float addrspace(1)* %tmp16, align 4 + %tmp18 = getelementptr i8, i8 addrspace(1)* %b, i64 28 + %tmp19 = bitcast i8 addrspace(1)* %tmp18 to float addrspace(1)* + %tmp20 = load float, float addrspace(1)* %tmp19, align 4 + + %tmp21 = getelementptr i8, i8 addrspace(1)* %a, i64 16 + %tmp22 = bitcast i8 addrspace(1)* %tmp21 to float addrspace(1)* + store float %tmp11, float addrspace(1)* %tmp22, align 4 + %tmp23 = getelementptr i8, i8 addrspace(1)* %a, i64 20 + %tmp24 = bitcast i8 addrspace(1)* %tmp23 to float addrspace(1)* + store float %tmp14, float addrspace(1)* %tmp24, align 4 + %tmp25 = getelementptr i8, i8 addrspace(1)* %a, i64 24 + %tmp26 = bitcast i8 addrspace(1)* %tmp25 to float addrspace(1)* + store float %tmp17, float addrspace(1)* %tmp26, align 4 + %tmp27 = getelementptr i8, i8 addrspace(1)* %a, i64 28 + %tmp28 = bitcast i8 addrspace(1)* %tmp27 to float addrspace(1)* + store float %tmp20, float addrspace(1)* %tmp28, align 4 + + ret void +} + +attributes #0 = { argmemonly nounwind } diff --git a/test/Transforms/LoadStoreVectorizer/NVPTX/lit.local.cfg b/test/Transforms/LoadStoreVectorizer/NVPTX/lit.local.cfg new file mode 100644 index 000000000000..a5e90f8e3c1d --- /dev/null +++ b/test/Transforms/LoadStoreVectorizer/NVPTX/lit.local.cfg @@ -0,0 +1,3 @@ +if not 'NVPTX' in config.root.targets: + config.unsupported = True + diff --git a/test/Transforms/LoadStoreVectorizer/NVPTX/merge-across-side-effects.ll b/test/Transforms/LoadStoreVectorizer/NVPTX/merge-across-side-effects.ll new file mode 100644 index 000000000000..72c13b4d12e5 --- /dev/null +++ b/test/Transforms/LoadStoreVectorizer/NVPTX/merge-across-side-effects.ll @@ -0,0 +1,209 @@ +; RUN: opt -mtriple=nvptx64-nvidia-cuda -load-store-vectorizer -S -o - %s | FileCheck %s + +; Check that the load/store vectorizer is willing to move loads/stores across +; intervening instructions only if it's safe. +; +; - Loads can be moved across instructions that don't write or throw. +; - Stores can only be moved across instructions which don't read, write, or +; throw. + +declare void @fn() +declare void @fn_nounwind() #0 +declare void @fn_nounwind_writeonly() #1 +declare void @fn_nounwind_readonly() #2 +declare void @fn_writeonly() #3 +declare void @fn_readonly() #4 +declare void @fn_readnone() #5 + +; CHECK-LABEL: @load_fn +; CHECK: load +; CHECK: call void @fn() +; CHECK: load +define void @load_fn(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + %v0 = load i32, i32* %p, align 8 + call void @fn() + %v1 = load i32, i32* %p.1, align 4 + ret void +} + +; CHECK-LABEL: @load_fn_nounwind +; CHECK: load +; CHECK: call void @fn_nounwind() +; CHECK: load +define void @load_fn_nounwind(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + %v0 = load i32, i32* %p, align 8 + call void @fn_nounwind() #0 + %v1 = load i32, i32* %p.1, align 4 + ret void +} + +; CHECK-LABEL: @load_fn_nounwind_writeonly +; CHECK: load +; CHECK: call void @fn_nounwind_writeonly() +; CHECK: load +define void @load_fn_nounwind_writeonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + %v0 = load i32, i32* %p, align 8 + call void @fn_nounwind_writeonly() #1 + %v1 = load i32, i32* %p.1, align 4 + ret void +} + +; CHECK-LABEL: @load_fn_nounwind_readonly +; CHECK-DAG: load <2 x i32> +; CHECK-DAG: call void @fn_nounwind_readonly() +define void @load_fn_nounwind_readonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + %v0 = load i32, i32* %p, align 8 + call void @fn_nounwind_readonly() #2 + %v1 = load i32, i32* %p.1, align 4 + ret void +} + +; CHECK-LABEL: @load_fn_readonly +; CHECK: load +; CHECK: call void @fn_readonly +; CHECK: load +define void @load_fn_readonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + %v0 = load i32, i32* %p, align 8 + call void @fn_readonly() #4 + %v1 = load i32, i32* %p.1, align 4 + ret void +} + +; CHECK-LABEL: @load_fn_writeonly +; CHECK: load +; CHECK: call void @fn_writeonly() +; CHECK: load +define void @load_fn_writeonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + %v0 = load i32, i32* %p, align 8 + call void @fn_writeonly() #3 + %v1 = load i32, i32* %p.1, align 4 + ret void +} + +; CHECK-LABEL: @load_fn_readnone +; CHECK-DAG: load <2 x i32> +; CHECK-DAG: call void @fn_readnone() +define void @load_fn_readnone(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + %v0 = load i32, i32* %p, align 8 + call void @fn_readnone() #5 + %v1 = load i32, i32* %p.1, align 4 + ret void +} + +; ------------------------------------------------ +; Same tests, but now for stores instead of loads. +; ------------------------------------------------ + +; CHECK-LABEL: @store_fn +; CHECK: store +; CHECK: call void @fn() +; CHECK: store +define void @store_fn(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + store i32 0, i32* %p + call void @fn() + store i32 0, i32* %p.1 + ret void +} + +; CHECK-LABEL: @store_fn_nounwind +; CHECK: store +; CHECK: call void @fn_nounwind() +; CHECK: store +define void @store_fn_nounwind(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + store i32 0, i32* %p + call void @fn_nounwind() #0 + store i32 0, i32* %p.1 + ret void +} + +; CHECK-LABEL: @store_fn_nounwind_writeonly +; CHECK: store +; CHECK: call void @fn_nounwind_writeonly() +; CHECK: store +define void @store_fn_nounwind_writeonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + store i32 0, i32* %p + call void @fn_nounwind_writeonly() #1 + store i32 0, i32* %p.1 + ret void +} + +; CHECK-LABEL: @store_fn_nounwind_readonly +; CHECK: store +; CHECK: call void @fn_nounwind_readonly() +; CHECK: store +define void @store_fn_nounwind_readonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + store i32 0, i32* %p + call void @fn_nounwind_readonly() #2 + store i32 0, i32* %p.1 + ret void +} + +; CHECK-LABEL: @store_fn_readonly +; CHECK: store +; CHECK: call void @fn_readonly +; CHECK: store +define void @store_fn_readonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + store i32 0, i32* %p + call void @fn_readonly() #4 + store i32 0, i32* %p.1 + ret void +} + +; CHECK-LABEL: @store_fn_writeonly +; CHECK: store +; CHECK: call void @fn_writeonly() +; CHECK: store +define void @store_fn_writeonly(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + store i32 0, i32* %p + call void @fn_writeonly() #3 + store i32 0, i32* %p.1 + ret void +} + +; This is the only store idiom we can vectorize. +; CHECK-LABEL: @store_fn_readnone +; CHECK-DAG: store <2 x i32> +; CHECK-DAG: call void @fn_readnone() +define void @store_fn_readnone(i32* %p) #0 { + %p.1 = getelementptr i32, i32* %p, i32 1 + + store i32 0, i32* %p, align 8 + call void @fn_readnone() #5 + store i32 0, i32* %p.1, align 8 + ret void +} + + +attributes #0 = { nounwind } +attributes #1 = { nounwind writeonly } +attributes #2 = { nounwind readonly } +attributes #3 = { writeonly } +attributes #4 = { readonly } +; readnone implies nounwind, so no need to test separately +attributes #5 = { nounwind readnone } diff --git a/test/Transforms/LoadStoreVectorizer/NVPTX/non-instr-bitcast.ll b/test/Transforms/LoadStoreVectorizer/NVPTX/non-instr-bitcast.ll new file mode 100644 index 000000000000..ff5e54f03ae6 --- /dev/null +++ b/test/Transforms/LoadStoreVectorizer/NVPTX/non-instr-bitcast.ll @@ -0,0 +1,14 @@ +; RUN: opt -mtriple=nvptx64-nvidia-cuda -load-store-vectorizer -S -o - %s | FileCheck %s + +; Load from a constant. This can be vectorized, but shouldn't crash us. + +@global = internal addrspace(1) constant [4 x float] [float 0xBF71111120000000, float 0x3F70410420000000, float 0xBF81111120000000, float 0x3FB5555560000000], align 4 + +define void @foo() { + ; CHECK: load <4 x float> + %a = load float, float addrspace(1)* getelementptr inbounds ([4 x float], [4 x float] addrspace(1)* @global, i64 0, i64 0), align 16 + %b = load float, float addrspace(1)* getelementptr inbounds ([4 x float], [4 x float] addrspace(1)* @global, i64 0, i64 1), align 4 + %c = load float, float addrspace(1)* getelementptr inbounds ([4 x float], [4 x float] addrspace(1)* @global, i64 0, i64 2), align 4 + %d = load float, float addrspace(1)* getelementptr inbounds ([4 x float], [4 x float] addrspace(1)* @global, i64 0, i64 3), align 4 + ret void +} diff --git a/test/Transforms/LoadStoreVectorizer/NVPTX/propagate-invariance-metadata.ll b/test/Transforms/LoadStoreVectorizer/NVPTX/propagate-invariance-metadata.ll new file mode 100644 index 000000000000..ac0660e7833a --- /dev/null +++ b/test/Transforms/LoadStoreVectorizer/NVPTX/propagate-invariance-metadata.ll @@ -0,0 +1,17 @@ +; RUN: opt -load-store-vectorizer -march=nvptx64 -mcpu=sm_35 -S < %s | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64" +target triple = "nvptx64-nvidia-cuda" + +; CHECK-LABEL: @foo +define i32 @foo(i32* %ptr) { + %ptr1 = getelementptr i32, i32* %ptr, i32 1 + %p1 = addrspacecast i32* %ptr1 to i32 addrspace(1)* + ; CHECK: load <2 x i32>, <2 x i32>* %{{[0-9]+}}, align 8, !invariant.load !0 + %v0 = load i32, i32* %ptr, align 8, !invariant.load !0 + %v1 = load i32, i32* %ptr1, align 4, !invariant.load !0 + %sum = add i32 %v0, %v1 + ret i32 %sum +} + +!0 = !{} diff --git a/test/Transforms/LoadStoreVectorizer/X86/correct-order.ll b/test/Transforms/LoadStoreVectorizer/X86/correct-order.ll index b98014e76cb6..fd2ae51fc1f0 100644 --- a/test/Transforms/LoadStoreVectorizer/X86/correct-order.ll +++ b/test/Transforms/LoadStoreVectorizer/X86/correct-order.ll @@ -1,14 +1,15 @@ -; RUN: opt -mtriple=x86-linux -load-store-vectorizer -S -o - %s | FileCheck %s +; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -S -o - %s | FileCheck %s target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" ; CHECK-LABEL: @correct_order( -; CHECK: bitcast i32* -; CHECK: load <2 x i32> -; CHECK: load i32 -; CHECK: bitcast i32* +; CHECK: [[LOAD_PTR:%[0-9]+]] = bitcast i32* %next.gep1 +; CHECK: load <2 x i32>, <2 x i32>* [[LOAD_PTR]] +; CHECK: load i32, i32* %next.gep +; CHECK: [[STORE_PTR:%[0-9]+]] = bitcast i32* %next.gep ; CHECK: store <2 x i32> -; CHECK: load i32 +; CHECK-SAME: <2 x i32>* [[STORE_PTR]] +; CHECK: load i32, i32* %next.gep1 define void @correct_order(i32* noalias %ptr) { %next.gep = getelementptr i32, i32* %ptr, i64 0 %next.gep1 = getelementptr i32, i32* %ptr, i64 1 diff --git a/test/Transforms/LoadStoreVectorizer/X86/preserve-order32.ll b/test/Transforms/LoadStoreVectorizer/X86/preserve-order32.ll index 9a7b294e4ced..12d882a51fa2 100644 --- a/test/Transforms/LoadStoreVectorizer/X86/preserve-order32.ll +++ b/test/Transforms/LoadStoreVectorizer/X86/preserve-order32.ll @@ -17,8 +17,8 @@ target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-p24: define void @preserve_order_32(%struct.buffer_t* noalias %buff) #0 { entry: %tmp1 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %buff, i32 0, i32 1 - %buff.p = load i8*, i8** %tmp1, align 8 - %buff.val = load i8, i8* %buff.p, align 8 + %buff.p = load i8*, i8** %tmp1 + %buff.val = load i8, i8* %buff.p store i8 0, i8* %buff.p, align 8 %tmp0 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %buff, i32 0, i32 0 %buff.int = load i32, i32* %tmp0, align 8 diff --git a/test/Transforms/LoadStoreVectorizer/X86/preserve-order64.ll b/test/Transforms/LoadStoreVectorizer/X86/preserve-order64.ll index 23c43863015b..bf75ecf62955 100644 --- a/test/Transforms/LoadStoreVectorizer/X86/preserve-order64.ll +++ b/test/Transforms/LoadStoreVectorizer/X86/preserve-order64.ll @@ -1,4 +1,4 @@ -; RUN: opt -mtriple=x86-linux -load-store-vectorizer -S -o - %s | FileCheck %s +; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -S -o - %s | FileCheck %s target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" @@ -18,11 +18,11 @@ target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" define void @preserve_order_64(%struct.buffer_t* noalias %buff) #0 { entry: %tmp1 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %buff, i64 0, i32 1 - %buff.p = load i8*, i8** %tmp1, align 8 - %buff.val = load i8, i8* %buff.p, align 8 + %buff.p = load i8*, i8** %tmp1 + %buff.val = load i8, i8* %buff.p store i8 0, i8* %buff.p, align 8 %tmp0 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %buff, i64 0, i32 0 - %buff.int = load i64, i64* %tmp0, align 8 + %buff.int = load i64, i64* %tmp0, align 16 ret void } @@ -36,12 +36,12 @@ define void @transitive_reorder(%struct.buffer_t* noalias %buff, %struct.nested. entry: %nest0_0 = getelementptr inbounds %struct.nested.buffer, %struct.nested.buffer* %nest, i64 0, i32 0 %tmp1 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %nest0_0, i64 0, i32 1 - %buff.p = load i8*, i8** %tmp1, align 8 - %buff.val = load i8, i8* %buff.p, align 8 + %buff.p = load i8*, i8** %tmp1 + %buff.val = load i8, i8* %buff.p store i8 0, i8* %buff.p, align 8 %nest1_0 = getelementptr inbounds %struct.nested.buffer, %struct.nested.buffer* %nest, i64 0, i32 0 %tmp0 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %nest1_0, i64 0, i32 0 - %buff.int = load i64, i64* %tmp0, align 8 + %buff.int = load i64, i64* %tmp0, align 16 ret void } @@ -55,8 +55,8 @@ entry: define void @no_vect_phi(i32* noalias %ptr, %struct.buffer_t* noalias %buff) { entry: %tmp1 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %buff, i64 0, i32 1 - %buff.p = load i8*, i8** %tmp1, align 8 - %buff.val = load i8, i8* %buff.p, align 8 + %buff.p = load i8*, i8** %tmp1 + %buff.val = load i8, i8* %buff.p store i8 0, i8* %buff.p, align 8 br label %"for something" @@ -64,7 +64,7 @@ entry: %index = phi i64 [ 0, %entry ], [ %index.next, %"for something" ] %tmp0 = getelementptr inbounds %struct.buffer_t, %struct.buffer_t* %buff, i64 0, i32 0 - %buff.int = load i64, i64* %tmp0, align 8 + %buff.int = load i64, i64* %tmp0, align 16 %index.next = add i64 %index, 8 %cmp_res = icmp eq i64 %index.next, 8 diff --git a/test/Transforms/LoadStoreVectorizer/X86/subchain-interleaved.ll b/test/Transforms/LoadStoreVectorizer/X86/subchain-interleaved.ll index cee7d9f8f9b5..915b94ac1557 100644 --- a/test/Transforms/LoadStoreVectorizer/X86/subchain-interleaved.ll +++ b/test/Transforms/LoadStoreVectorizer/X86/subchain-interleaved.ll @@ -1,4 +1,4 @@ -; RUN: opt -mtriple=x86-linux -load-store-vectorizer -S -o - %s | FileCheck %s +; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -S -o - %s | FileCheck %s target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" @@ -85,3 +85,33 @@ define void @chain_prefix_suffix(i32* noalias %ptr) { ret void } +; FIXME: If the chain is too long and TLI says misaligned is not fast, +; then LSV fails to vectorize anything in that chain. +; To reproduce below, add a tmp5 (ptr+4) and load tmp5 into l6 and l7. + +; CHECK-LABEL: @interleave_get_longest +; CHECK: load <3 x i32> +; CHECK: load i32 +; CHECK: store <2 x i32> zeroinitializer +; CHECK: load i32 +; CHECK: load i32 +; CHECK: load i32 + +define void @interleave_get_longest(i32* noalias %ptr) { + %tmp1 = getelementptr i32, i32* %ptr, i64 0 + %tmp2 = getelementptr i32, i32* %ptr, i64 1 + %tmp3 = getelementptr i32, i32* %ptr, i64 2 + %tmp4 = getelementptr i32, i32* %ptr, i64 3 + + %l1 = load i32, i32* %tmp2, align 4 + %l2 = load i32, i32* %tmp1, align 4 + store i32 0, i32* %tmp2, align 4 + store i32 0, i32* %tmp1, align 4 + %l3 = load i32, i32* %tmp2, align 4 + %l4 = load i32, i32* %tmp3, align 4 + %l5 = load i32, i32* %tmp4, align 4 + %l6 = load i32, i32* %tmp4, align 4 + %l7 = load i32, i32* %tmp4, align 4 + + ret void +} |
