File: arm64-fast-isel-gv.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (41 lines) | stat: -rw-r--r-- 1,421 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
; RUN: llc -O0 -fast-isel -fast-isel-abort=1 -verify-machineinstrs -mtriple=arm64-apple-darwin < %s | FileCheck %s

; Test load/store of global value from global offset table.
@seed = common global i64 0, align 8

define void @Initrand() nounwind {
entry:
; CHECK: @Initrand
; CHECK: adrp [[REG:x[0-9]+]], _seed@GOTPAGE
; CHECK: ldr  [[REG2:x[0-9]+]], [[[REG]], _seed@GOTPAGEOFF]
; CHECK: str  {{x[0-9]+}}, [[[REG2]]]
  store i64 74755, ptr @seed, align 8
  ret void
}

define i32 @Rand() nounwind {
entry:
; CHECK: @Rand
; CHECK: adrp [[REG1:x[0-9]+]], _seed@GOTPAGE
; CHECK: ldr  [[REG2:x[0-9]+]], [[[REG1]], _seed@GOTPAGEOFF]
; CHECK: ldr  [[REG5:x[0-9]+]], [[[REG2]]]
; CHECK: mov  [[REG4:x[0-9]+]], #1309
; CHECK: mul  [[REG6:x[0-9]+]], [[REG5]], [[REG4]]
; CHECK: mov  [[REG3:x[0-9]+]], #13849
; CHECK: add  [[REG7:x[0-9]+]], [[REG6]], [[REG3]]
; CHECK: and  [[REG8:x[0-9]+]], [[REG7]], #0xffff
; CHECK: adrp [[REG1:x[0-9]+]], _seed@GOTPAGE
; CHECK: ldr  [[REG1]], [[[REG1]], _seed@GOTPAGEOFF]
; CHECK: str  [[REG8]], [[[REG1]]]
; CHECK: adrp [[REG1:x[0-9]+]], _seed@GOTPAGE
; CHECK: ldr  [[REG1]], [[[REG1]], _seed@GOTPAGEOFF]
; CHECK: ldr  {{x[0-9]+}}, [[[REG1]]]
  %0 = load i64, ptr @seed, align 8
  %mul = mul nsw i64 %0, 1309
  %add = add nsw i64 %mul, 13849
  %and = and i64 %add, 65535
  store i64 %and, ptr @seed, align 8
  %1 = load i64, ptr @seed, align 8
  %conv = trunc i64 %1 to i32
  ret i32 %conv
}