reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s

; CHECK-LABEL: @test1
; CHECK: sbfx {{x[0-9]+}}, x0, #23, #9
define i64 @test1(i32 %a) {
  %tmp = ashr i32 %a, 23
  %ext = sext i32 %tmp to i64
  %res = add i64 %ext, 1
  ret i64 %res
}

; CHECK-LABEL: @test2
; CHECK: sbfx w0, w0, #23, #8
define signext i8 @test2(i32 %a) {
  %tmp = ashr i32 %a, 23
  %res = trunc i32 %tmp to i8
  ret i8 %res
}

; CHECK-LABEL: @test3
; CHECK: sbfx w0, w0, #23, #8
define signext i8 @test3(i32 %a) {
  %tmp = lshr i32 %a, 23
  %res = trunc i32 %tmp to i8
  ret i8 %res
}

; CHECK-LABEL: @test4
; CHECK: sbfx w0, w0, #15, #16
define signext i16 @test4(i32 %a) {
  %tmp = lshr i32 %a, 15
  %res = trunc i32 %tmp to i16
  ret i16 %res
}

; CHECK-LABEL: @test5
; CHECK: sbfx w0, w0, #16, #8
define signext i8 @test5(i64 %a) {
  %tmp = lshr i64 %a, 16
  %res = trunc i64 %tmp to i8
  ret i8 %res
}

; CHECK-LABEL: @test6
; CHECK: sbfx x0, x0, #30, #8
define signext i8 @test6(i64 %a) {
  %tmp = lshr i64 %a, 30
  %res = trunc i64 %tmp to i8
  ret i8 %res
}

; CHECK-LABEL: @test7
; CHECK: sbfx x0, x0, #23, #16
define signext i16 @test7(i64 %a) {
  %tmp = lshr i64 %a, 23
  %res = trunc i64 %tmp to i16
  ret i16 %res
}

; CHECK-LABEL: @test8
; CHECK: asr w0, w0, #25
define signext i8 @test8(i32 %a) {
  %tmp = ashr i32 %a, 25
  %res = trunc i32 %tmp to i8
  ret i8 %res
}

; CHECK-LABEL: @test9
; CHECK: lsr w0, w0, #25
define signext i8 @test9(i32 %a) {
  %tmp = lshr i32 %a, 25
  %res = trunc i32 %tmp to i8
  ret i8 %res
}

; CHECK-LABEL: @test10
; CHECK: lsr x0, x0, #49
define signext i16 @test10(i64 %a) {
  %tmp = lshr i64 %a, 49
  %res = trunc i64 %tmp to i16
  ret i16 %res
}

; SHR with multiple uses is fine as SXTH and SBFX are both aliases of SBFM.
; However, allowing the transformation means the SHR and SBFX can execute in
; parallel.
;
; CHECK-LABEL: @test11
; CHECK: lsr x1, x0, #23
; CHECK: sbfx x0, x0, #23, #16
define void @test11(i64 %a) {
  %tmp = lshr i64 %a, 23
  %res = trunc i64 %tmp to i16
  call void @use(i16 %res, i64 %tmp)
  ret void
}

declare void @use(i16 signext, i64)

; CHECK-LABEL: test_complex_node:
; CHECK: ldr d0, [x0], #8
; CHECK: ubfx x[[VAL:[0-9]+]], x0, #5, #27
; CHECK: str w[[VAL]], [x2]
define <2 x i32> @test_complex_node(<2 x i32>* %addr, <2 x i32>** %addr2, i32* %bf ) {
  %vec = load <2 x i32>, <2 x i32>* %addr

  %vec.next = getelementptr <2 x i32>, <2 x i32>* %addr, i32 1
  store <2 x i32>* %vec.next, <2 x i32>** %addr2
  %lo = ptrtoint <2 x i32>* %vec.next to i32

  %val = lshr i32 %lo, 5
  store i32 %val, i32* %bf

  ret <2 x i32> %vec
}