1 ; RUN: llc -fast-isel-sink-local-values -O0 -fast-isel -fast-isel-abort=1 -verify-machineinstrs -mtriple=arm64-apple-darwin < %s | FileCheck %s
3 ; Test load/store of global value from global offset table.
4 @seed = common global i64 0, align 8
6 define void @Initrand() nounwind {
9 ; CHECK: adrp [[REG:x[0-9]+]], _seed@GOTPAGE
10 ; CHECK: ldr [[REG2:x[0-9]+]], {{\[}}[[REG]], _seed@GOTPAGEOFF{{\]}}
11 ; CHECK: str {{x[0-9]+}}, {{\[}}[[REG2]]{{\]}}
12 store i64 74755, i64* @seed, align 8
16 define i32 @Rand() nounwind {
19 ; CHECK: adrp [[REG1:x[0-9]+]], _seed@GOTPAGE
20 ; CHECK: ldr [[REG2:x[0-9]+]], {{\[}}[[REG1]], _seed@GOTPAGEOFF{{\]}}
21 ; CHECK: ldr [[REG5:x[0-9]+]], {{\[}}[[REG2]]{{\]}}
22 ; CHECK: mov [[REG4:x[0-9]+]], #1309
23 ; CHECK: mul [[REG6:x[0-9]+]], [[REG5]], [[REG4]]
24 ; CHECK: mov [[REG3:x[0-9]+]], #13849
25 ; CHECK: add [[REG7:x[0-9]+]], [[REG6]], [[REG3]]
26 ; CHECK: and [[REG8:x[0-9]+]], [[REG7]], #0xffff
27 ; CHECK: str [[REG8]], {{\[}}[[REG1]]{{\]}}
28 ; CHECK: ldr {{x[0-9]+}}, {{\[}}[[REG1]]{{\]}}
29 %0 = load i64, i64* @seed, align 8
30 %mul = mul nsw i64 %0, 1309
31 %add = add nsw i64 %mul, 13849
32 %and = and i64 %add, 65535
33 store i64 %and, i64* @seed, align 8
34 %1 = load i64, i64* @seed, align 8
35 %conv = trunc i64 %1 to i32