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
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=arm-eabi %s -o - | FileCheck %s
; RUN: llc -mtriple=armv6m-eabi %s -o - | FileCheck %s --check-prefix=EXPAND

define i64 @test_shl(i64 %val, i64 %amt) {
; CHECK-LABEL: test_shl:
; CHECK:       @ %bb.0:
; CHECK-NEXT:    rsb r3, r2, #32
; CHECK-NEXT:    lsr r3, r0, r3
; CHECK-NEXT:    orr r1, r3, r1, lsl r2
; CHECK-NEXT:    subs r3, r2, #32
; CHECK-NEXT:    lslpl r1, r0, r3
; CHECK-NEXT:    lsl r0, r0, r2
; CHECK-NEXT:    movpl r0, #0
; CHECK-NEXT:    mov pc, lr
;
; EXPAND-LABEL: test_shl:
; EXPAND:       @ %bb.0:
; EXPAND-NEXT:    .save {r7, lr}
; EXPAND-NEXT:    push {r7, lr}
; EXPAND-NEXT:    bl __aeabi_llsl
; EXPAND-NEXT:    pop {r7, pc}
  %res = shl i64 %val, %amt
  ret i64 %res
}

; Explanation for lshr is pretty much the reverse of shl.
define i64 @test_lshr(i64 %val, i64 %amt) {
; CHECK-LABEL: test_lshr:
; CHECK:       @ %bb.0:
; CHECK-NEXT:    rsb r3, r2, #32
; CHECK-NEXT:    lsr r0, r0, r2
; CHECK-NEXT:    orr r0, r0, r1, lsl r3
; CHECK-NEXT:    subs r3, r2, #32
; CHECK-NEXT:    lsrpl r0, r1, r3
; CHECK-NEXT:    lsr r1, r1, r2
; CHECK-NEXT:    movpl r1, #0
; CHECK-NEXT:    mov pc, lr
;
; EXPAND-LABEL: test_lshr:
; EXPAND:       @ %bb.0:
; EXPAND-NEXT:    .save {r7, lr}
; EXPAND-NEXT:    push {r7, lr}
; EXPAND-NEXT:    bl __aeabi_llsr
; EXPAND-NEXT:    pop {r7, pc}
  %res = lshr i64 %val, %amt
  ret i64 %res
}

; One minor difference for ashr: the high bits must be "hi >> 31" if the shift
; amount is large to get the right sign bit.
define i64 @test_ashr(i64 %val, i64 %amt) {
; CHECK-LABEL: test_ashr:
; CHECK:       @ %bb.0:
; CHECK-NEXT:    asr r3, r1, r2
; CHECK-NEXT:    subs r12, r2, #32
; CHECK-NEXT:    lsr r0, r0, r2
; CHECK-NEXT:    rsb r2, r2, #32
; CHECK-NEXT:    asrpl r3, r1, #31
; CHECK-NEXT:    orr r0, r0, r1, lsl r2
; CHECK-NEXT:    asrpl r0, r1, r12
; CHECK-NEXT:    mov r1, r3
; CHECK-NEXT:    mov pc, lr
;
; EXPAND-LABEL: test_ashr:
; EXPAND:       @ %bb.0:
; EXPAND-NEXT:    .save {r7, lr}
; EXPAND-NEXT:    push {r7, lr}
; EXPAND-NEXT:    bl __aeabi_lasr
; EXPAND-NEXT:    pop {r7, pc}
  %res = ashr i64 %val, %amt
  ret i64 %res
}