[LSV] Don't assume that loads/stores appear in address order in the BB.

Summary:
getVectorizablePrefix previously didn't work properly in the face of
aliasing loads/stores.  It unwittingly assumed that the loads/stores
appeared in the BB in address order.  If they didn't, it would do the
wrong thing.

Reviewers: asbirlea, tstellarAMD

Subscribers: arsenm, llvm-commits, mzolotukhin

Differential Revision: https://reviews.llvm.org/D22535

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276072 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Lebar
2016-07-20 00:55:12 +00:00
parent 30f6cf738e
commit dbf6ad39ae
2 changed files with 70 additions and 20 deletions
@@ -86,4 +86,34 @@ define float @insert_store_point_alias(float addrspace(1)* nocapture %a, i64 %id
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 }