# RUN: llc -mtriple=aarch64-none-linux-gnu -start-after branch-folder -stop-after branch-folder -o - %s | FileCheck %s

--- |

  @var_i32 = global i32 42
  @var_i64 = global i64 0

  define void @sub_small() {
  entry:
    %val32 = load i32, i32* @var_i32
    %newval32 = sub i32 %val32, 4095
    store i32 %newval32, i32* @var_i32
    %val64 = load i64, i64* @var_i64
    %newval64 = sub i64 %val64, 52
    store i64 %newval64, i64* @var_i64
    ret void
  }

...
---
name:            sub_small
body: |
  bb.0.entry:
  ; CHECK:      %x8 = ADRP target-flags(aarch64-page) @var_i32
  ; CHECK-NEXT: %x9 = ADRP target-flags(aarch64-page) @var_i64
  ; CHECK-NEXT: %w10 = LDRWui %x8, target-flags(aarch64-pageoff, aarch64-nc) @var_i32
  ; CHECK-NEXT: %x11 = LDRXui %x9, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @var_i64
  ; CHECK:      STRWui killed %w10, killed %x8, target-flags(aarch64-nc) @var_i32
  ; CHECK:      STRXui killed %x11, killed %x9, target-flags(aarch64-pageoff, aarch64-nc) @var_i64
    %x8 = ADRP target-flags(aarch64-page) @var_i32
    %x9 = ADRP target-flags(aarch64-page) @var_i64
    %w10 = LDRWui %x8, target-flags(aarch64-pageoff, aarch64-nc) @var_i32
    %x11 = LDRXui %x9, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @var_i64
    %w10 = SUBWri killed %w10, 4095, 0
    %x11 = SUBXri killed %x11, 52, 0
    STRWui killed %w10, killed %x8, target-flags(aarch64-nc) @var_i32
    STRXui killed %x11, killed %x9, target-flags(aarch64-pageoff, aarch64-nc) @var_i64
    RET_ReallyLR
...