[LoadStoreVectorizer] Support opaque pointers

There are remaining redundant bitcasts.
This commit is contained in:
Nikita Popov 2021-06-27 15:40:43 +02:00
parent f1a6430272
commit a9129f8964
2 changed files with 23 additions and 2 deletions

View File

@ -312,8 +312,8 @@ bool Vectorizer::isConsecutiveAccess(Value *A, Value *B) {
return false;
// Make sure that A and B are different pointers of the same size type.
Type *PtrATy = PtrA->getType()->getPointerElementType();
Type *PtrBTy = PtrB->getType()->getPointerElementType();
Type *PtrATy = getLoadStoreType(A);
Type *PtrBTy = getLoadStoreType(B);
if (PtrA == PtrB ||
PtrATy->isVectorTy() != PtrBTy->isVectorTy() ||
DL.getTypeStoreSize(PtrATy) != DL.getTypeStoreSize(PtrBTy) ||

View File

@ -0,0 +1,21 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -S < %s | FileCheck %s
define void @test(ptr %ptr) {
; CHECK-LABEL: @test(
; CHECK-NEXT: [[TMP1:%.*]] = bitcast ptr [[PTR:%.*]] to <2 x i32>*
; CHECK-NEXT: [[TMP2:%.*]] = load <2 x i32>, <2 x i32>* [[TMP1]], align 4
; CHECK-NEXT: [[L11:%.*]] = extractelement <2 x i32> [[TMP2]], i32 0
; CHECK-NEXT: [[L22:%.*]] = extractelement <2 x i32> [[TMP2]], i32 1
; CHECK-NEXT: [[TMP3:%.*]] = bitcast ptr [[PTR]] to <2 x i32>*
; CHECK-NEXT: store <2 x i32> zeroinitializer, <2 x i32>* [[TMP3]], align 4
; CHECK-NEXT: ret void
;
%ptr2 = getelementptr i32, ptr %ptr, i64 1
%l1 = load i32, ptr %ptr, align 4
%l2 = load i32, ptr %ptr2, align 4
store i32 0, ptr %ptr, align 4
store i32 0, ptr %ptr2, align 4
ret void
}