54 lines · plain
1; RUN: opt < %s -passes=globalopt -S | FileCheck %s2 3; globalopt should not sra the global, because it can't see the index.4 5%struct.X = type { [3 x i32], [3 x i32] }6 7; CHECK: @Y = internal unnamed_addr global [3 x %struct.X] zeroinitializer8@Y = internal global [3 x %struct.X] zeroinitializer9 10@addr = external global i811 12define void @frob() {13 store i32 1, ptr getelementptr inbounds ([3 x %struct.X], ptr @Y, i64 0, i64 0, i32 0, i64 ptrtoint (ptr @addr to i64)), align 414 ret void15}16 17; CHECK-LABEL: @borf18; CHECK: %a = load19; CHECK: %b = load20; CHECK: add i32 %a, %b21define i32 @borf(i64 %i, i64 %j) {22 %a = load i32, ptr @Y23 %q = getelementptr inbounds [3 x %struct.X], ptr @Y, i64 0, i64 0, i32 1, i64 024 %b = load i32, ptr %q25 %c = add i32 %a, %b26 ret i32 %c27}28 29; CHECK-LABEL: @borg30; CHECK: %a = load31; CHECK: %b = load32; CHECK: add i32 %a, %b33define i32 @borg(i64 %i, i64 %j) {34 %p = getelementptr inbounds [3 x %struct.X], ptr @Y, i64 0, i64 1, i32 0, i64 135 %a = load i32, ptr %p36 %q = getelementptr inbounds [3 x %struct.X], ptr @Y, i64 0, i64 1, i32 1, i64 137 %b = load i32, ptr %q38 %c = add i32 %a, %b39 ret i32 %c40}41 42; CHECK-LABEL: @borh43; CHECK: %a = load44; CHECK: %b = load45; CHECK: add i32 %a, %b46define i32 @borh(i64 %i, i64 %j) {47 %p = getelementptr inbounds [3 x %struct.X], ptr @Y, i64 0, i64 2, i32 0, i64 248 %a = load i32, ptr %p49 %q = getelementptr inbounds [3 x %struct.X], ptr @Y, i64 0, i64 2, i32 1, i64 250 %b = load i32, ptr %q51 %c = add i32 %a, %b52 ret i32 %c53}54