blob: bce193b5e851b5ecb4f5c99409ed16ab9e22511b [file] [log] [blame]
Kristof Beylsc08f7052016-05-03 08:33:26 +00001; RUN: opt -O3 -S < %s | FileCheck %s
2target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
3target triple = "aarch64"
4
5@v = internal unnamed_addr global i32 0, align 4
6@p = common global i32* null, align 8
7
8; Function Attrs: norecurse nounwind
9define void @f(i32 %n) {
10entry:
11 %0 = load i32, i32* @v, align 4
12 %inc = add nsw i32 %0, 1
13 store i32 %inc, i32* @v, align 4
14 %1 = load i32*, i32** @p, align 8
15 store i32 %n, i32* %1, align 4
16 %2 = load i32, i32* @v, align 4
17 %inc1 = add nsw i32 %2, 1
18 store i32 %inc1, i32* @v, align 4
19 ret void
20}
21
22; check variable v is loaded only once after optimization, which should be
23; prove that globalsAA survives until the optimization that can use it to
24; optimize away the duplicate load/stores on variable v.
25; CHECK: load i32, i32* @v, align 4
26; CHECK-NOT: load i32, i32* @v, align 4