; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes='sroa<preserve-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG
; RUN: opt < %s -passes='sroa<modify-cfg>' -S | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG
;
; Make sure the llvm.access.group meta-data is preserved
; when a load/store is replaced with another load/store by sroa
; Ensure this is done for casting too.
;
%CMPLX = type { float, float }
define dso_local void @test() {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[PART:%.*]] = alloca [[CMPLX:%.*]], align 8
; CHECK-NEXT: [[DUMMY:%.*]] = sext i16 0 to i64
; CHECK-NEXT: [[T:%.*]] = getelementptr [[CMPLX]], ptr [[PART]], i64 [[DUMMY]]
; CHECK-NEXT: [[X371:%.*]] = load i32, ptr [[T]], align 8, !llvm.access.group [[ACC_GRP0:![0-9]+]]
; CHECK-NEXT: [[T_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr [[T]], i64 4
; CHECK-NEXT: [[X372:%.*]] = load i32, ptr [[T_SROA_IDX]], align 4, !llvm.access.group [[ACC_GRP0]]
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32 [[X371]] to float
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32 [[X372]] to float
; CHECK-NEXT: ret void
;
entry:
%PART = alloca %CMPLX, align 8
%PREV = alloca %CMPLX, align 8
store float 0.000000e+00, ptr %PREV, align 4
%i2 = getelementptr %CMPLX, ptr %PREV, i32 0, i32 1
store float 0.000000e+00, ptr %i2, align 4
%dummy = sext i16 0 to i64
%T = getelementptr %CMPLX, ptr %PART, i64 %dummy
%X37 = load i64, ptr %T, align 8, !llvm.access.group !0
store i64 %X37, ptr %PREV, align 8
ret void
}
!0 = distinct !{}
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK-MODIFY-CFG: {{.*}}
; CHECK-PRESERVE-CFG: {{.*}}