1; RUN: opt -gvn -S < %s | FileCheck %s
2
3; Make sure we don't crash when analyzing an addrspacecast in
4; GetPointerBaseWithConstantOffset()
5
6target datalayout = "e-p:32:32-p4:64:64"
7
8define i32 @addrspacecast-crash() {
9; CHECK-LABEL: @addrspacecast-crash
10; CHECK: %tmp = alloca [25 x i64]
11; CHECK: %tmp1 = getelementptr inbounds [25 x i64], [25 x i64]* %tmp, i32 0, i32 0
12; CHECK: %tmp2 = addrspacecast i64* %tmp1 to <8 x i64> addrspace(4)*
13; CHECK: store <8 x i64> zeroinitializer, <8 x i64> addrspace(4)* %tmp2
14; CHECK-NOT: load
15bb:
16  %tmp = alloca [25 x i64]
17  %tmp1 = getelementptr inbounds [25 x i64], [25 x i64]* %tmp, i32 0, i32 0
18  %tmp2 = addrspacecast i64* %tmp1 to <8 x i64> addrspace(4)*
19  %tmp3 = getelementptr inbounds <8 x i64>, <8 x i64> addrspace(4)* %tmp2, i64 0
20  store <8 x i64> zeroinitializer, <8 x i64> addrspace(4)* %tmp3
21  %tmp4 = getelementptr inbounds [25 x i64], [25 x i64]* %tmp, i32 0, i32 0
22  %tmp5 = addrspacecast i64* %tmp4 to i32 addrspace(4)*
23  %tmp6 = getelementptr inbounds i32, i32 addrspace(4)* %tmp5, i64 10
24  %tmp7 = load i32, i32 addrspace(4)* %tmp6, align 4
25  ret i32 %tmp7
26}
27