1 ; RUN: opt < %s -globalopt -S | FileCheck %s
3 ; globalopt should not sra the global, because it can't see the index.
5 %struct.X = type { [3 x i32], [3 x i32] }
7 ; CHECK: @Y = internal unnamed_addr global [3 x %struct.X] zeroinitializer
8 @Y = internal global [3 x %struct.X] zeroinitializer
10 @addr = external global i8
13 store i32 1, i32* getelementptr inbounds ([3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 0, i32 0, i64 ptrtoint (i8* @addr to i64)), align 4
20 ; CHECK: add i32 %a, %b
21 define i32 @borf(i64 %i, i64 %j) {
22 %p = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 0, i32 0, i64 0
23 %a = load i32, i32* %p
24 %q = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 0, i32 1, i64 0
25 %b = load i32, i32* %q
33 ; CHECK: add i32 %a, %b
34 define i32 @borg(i64 %i, i64 %j) {
35 %p = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 1, i32 0, i64 1
36 %a = load i32, i32* %p
37 %q = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 1, i32 1, i64 1
38 %b = load i32, i32* %q
46 ; CHECK: add i32 %a, %b
47 define i32 @borh(i64 %i, i64 %j) {
48 %p = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 2, i32 0, i64 2
49 %a = load i32, i32* %p
50 %q = getelementptr inbounds [3 x %struct.X], [3 x %struct.X]* @Y, i64 0, i64 2, i32 1, i64 2
51 %b = load i32, i32* %q