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
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s
; RUN: llc < %s -mtriple=aarch64-eabi -mattr -neon -aarch64-neon-syntax=apple | FileCheck -check-prefix=CHECK-NONEON %s

define i32 @cnt32_advsimd(i32 %x) nounwind readnone {
; CHECK-LABEL: cnt32_advsimd:
; CHECK:       // %bb.0:
; CHECK-NEXT:    mov w8, w0
; CHECK-NEXT:    fmov d0, x8
; CHECK-NEXT:    cnt.8b v0, v0
; CHECK-NEXT:    uaddlv.8b h0, v0
; CHECK-NEXT:    fmov w0, s0
; CHECK-NEXT:    ret
;
; CHECK-NONEON-LABEL: cnt32_advsimd:
; CHECK-NONEON:       // %bb.0:
; CHECK-NONEON-NEXT:    lsr w8, w0, #1
; CHECK-NONEON-NEXT:    and w8, w8, #0x55555555
; CHECK-NONEON-NEXT:    sub w8, w0, w8
; CHECK-NONEON-NEXT:    and w9, w8, #0x33333333
; CHECK-NONEON-NEXT:    lsr w8, w8, #2
; CHECK-NONEON-NEXT:    and w8, w8, #0x33333333
; CHECK-NONEON-NEXT:    add w8, w9, w8
; CHECK-NONEON-NEXT:    add w8, w8, w8, lsr #4
; CHECK-NONEON-NEXT:    and w8, w8, #0xf0f0f0f
; CHECK-NONEON-NEXT:    mov w9, #16843009
; CHECK-NONEON-NEXT:    mul w8, w8, w9
; CHECK-NONEON-NEXT:    lsr w0, w8, #24
; CHECK-NONEON-NEXT:    ret
  %cnt = tail call i32 @llvm.ctpop.i32(i32 %x)
  ret i32 %cnt
}

define i32 @cnt32_advsimd_2(<2 x i32> %x) {
; CHECK-LABEL: cnt32_advsimd_2:
; CHECK:       // %bb.0:
; CHECK-NEXT:    // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT:    fmov w0, s0
; CHECK-NEXT:    fmov d0, x0
; CHECK-NEXT:    cnt.8b v0, v0
; CHECK-NEXT:    uaddlv.8b h0, v0
; CHECK-NEXT:    fmov w0, s0
; CHECK-NEXT:    ret
;
; CHECK-NONEON-LABEL: cnt32_advsimd_2:
; CHECK-NONEON:       // %bb.0:
; CHECK-NONEON-NEXT:    lsr w8, w0, #1
; CHECK-NONEON-NEXT:    and w8, w8, #0x55555555
; CHECK-NONEON-NEXT:    sub w8, w0, w8
; CHECK-NONEON-NEXT:    and w9, w8, #0x33333333
; CHECK-NONEON-NEXT:    lsr w8, w8, #2
; CHECK-NONEON-NEXT:    and w8, w8, #0x33333333
; CHECK-NONEON-NEXT:    add w8, w9, w8
; CHECK-NONEON-NEXT:    add w8, w8, w8, lsr #4
; CHECK-NONEON-NEXT:    and w8, w8, #0xf0f0f0f
; CHECK-NONEON-NEXT:    mov w9, #16843009
; CHECK-NONEON-NEXT:    mul w8, w8, w9
; CHECK-NONEON-NEXT:    lsr w0, w8, #24
; CHECK-NONEON-NEXT:    ret
  %1 = extractelement <2 x i32> %x, i64 0
  %2 = tail call i32 @llvm.ctpop.i32(i32 %1)
  ret i32 %2
}

define i64 @cnt64_advsimd(i64 %x) nounwind readnone {
; CHECK-LABEL: cnt64_advsimd:
; CHECK:       // %bb.0:
; CHECK-NEXT:    fmov d0, x0
; CHECK-NEXT:    cnt.8b v0, v0
; CHECK-NEXT:    uaddlv.8b h0, v0
; CHECK-NEXT:    fmov w0, s0
; CHECK-NEXT:    ret
;
; CHECK-NONEON-LABEL: cnt64_advsimd:
; CHECK-NONEON:       // %bb.0:
; CHECK-NONEON-NEXT:    lsr x8, x0, #1
; CHECK-NONEON-NEXT:    and x8, x8, #0x5555555555555555
; CHECK-NONEON-NEXT:    sub x8, x0, x8
; CHECK-NONEON-NEXT:    and x9, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    lsr x8, x8, #2
; CHECK-NONEON-NEXT:    and x8, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    add x8, x9, x8
; CHECK-NONEON-NEXT:    add x8, x8, x8, lsr #4
; CHECK-NONEON-NEXT:    and x8, x8, #0xf0f0f0f0f0f0f0f
; CHECK-NONEON-NEXT:    mov x9, #72340172838076673
; CHECK-NONEON-NEXT:    mul x8, x8, x9
; CHECK-NONEON-NEXT:    lsr x0, x8, #56
; CHECK-NONEON-NEXT:    ret
  %cnt = tail call i64 @llvm.ctpop.i64(i64 %x)
  ret i64 %cnt
}

; Do not use AdvSIMD when -mno-implicit-float is specified.
; rdar://9473858

define i32 @cnt32(i32 %x) nounwind readnone noimplicitfloat {
; CHECK-LABEL: cnt32:
; CHECK:       // %bb.0:
; CHECK-NEXT:    lsr w8, w0, #1
; CHECK-NEXT:    and w8, w8, #0x55555555
; CHECK-NEXT:    sub w8, w0, w8
; CHECK-NEXT:    and w9, w8, #0x33333333
; CHECK-NEXT:    lsr w8, w8, #2
; CHECK-NEXT:    and w8, w8, #0x33333333
; CHECK-NEXT:    add w8, w9, w8
; CHECK-NEXT:    add w8, w8, w8, lsr #4
; CHECK-NEXT:    and w8, w8, #0xf0f0f0f
; CHECK-NEXT:    mov w9, #16843009
; CHECK-NEXT:    mul w8, w8, w9
; CHECK-NEXT:    lsr w0, w8, #24
; CHECK-NEXT:    ret
;
; CHECK-NONEON-LABEL: cnt32:
; CHECK-NONEON:       // %bb.0:
; CHECK-NONEON-NEXT:    lsr w8, w0, #1
; CHECK-NONEON-NEXT:    and w8, w8, #0x55555555
; CHECK-NONEON-NEXT:    sub w8, w0, w8
; CHECK-NONEON-NEXT:    and w9, w8, #0x33333333
; CHECK-NONEON-NEXT:    lsr w8, w8, #2
; CHECK-NONEON-NEXT:    and w8, w8, #0x33333333
; CHECK-NONEON-NEXT:    add w8, w9, w8
; CHECK-NONEON-NEXT:    add w8, w8, w8, lsr #4
; CHECK-NONEON-NEXT:    and w8, w8, #0xf0f0f0f
; CHECK-NONEON-NEXT:    mov w9, #16843009
; CHECK-NONEON-NEXT:    mul w8, w8, w9
; CHECK-NONEON-NEXT:    lsr w0, w8, #24
; CHECK-NONEON-NEXT:    ret
  %cnt = tail call i32 @llvm.ctpop.i32(i32 %x)
  ret i32 %cnt
}

define i64 @cnt64(i64 %x) nounwind readnone noimplicitfloat {
; CHECK-LABEL: cnt64:
; CHECK:       // %bb.0:
; CHECK-NEXT:    lsr x8, x0, #1
; CHECK-NEXT:    and x8, x8, #0x5555555555555555
; CHECK-NEXT:    sub x8, x0, x8
; CHECK-NEXT:    and x9, x8, #0x3333333333333333
; CHECK-NEXT:    lsr x8, x8, #2
; CHECK-NEXT:    and x8, x8, #0x3333333333333333
; CHECK-NEXT:    add x8, x9, x8
; CHECK-NEXT:    add x8, x8, x8, lsr #4
; CHECK-NEXT:    and x8, x8, #0xf0f0f0f0f0f0f0f
; CHECK-NEXT:    mov x9, #72340172838076673
; CHECK-NEXT:    mul x8, x8, x9
; CHECK-NEXT:    lsr x0, x8, #56
; CHECK-NEXT:    ret
;
; CHECK-NONEON-LABEL: cnt64:
; CHECK-NONEON:       // %bb.0:
; CHECK-NONEON-NEXT:    lsr x8, x0, #1
; CHECK-NONEON-NEXT:    and x8, x8, #0x5555555555555555
; CHECK-NONEON-NEXT:    sub x8, x0, x8
; CHECK-NONEON-NEXT:    and x9, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    lsr x8, x8, #2
; CHECK-NONEON-NEXT:    and x8, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    add x8, x9, x8
; CHECK-NONEON-NEXT:    add x8, x8, x8, lsr #4
; CHECK-NONEON-NEXT:    and x8, x8, #0xf0f0f0f0f0f0f0f
; CHECK-NONEON-NEXT:    mov x9, #72340172838076673
; CHECK-NONEON-NEXT:    mul x8, x8, x9
; CHECK-NONEON-NEXT:    lsr x0, x8, #56
; CHECK-NONEON-NEXT:    ret
  %cnt = tail call i64 @llvm.ctpop.i64(i64 %x)
  ret i64 %cnt
}

define i32 @ctpop_eq_one(i64 %x) nounwind readnone {
; CHECK-LABEL: ctpop_eq_one:
; CHECK:       // %bb.0:
; CHECK-NEXT:    fmov d0, x0
; CHECK-NEXT:    cnt.8b v0, v0
; CHECK-NEXT:    uaddlv.8b h0, v0
; CHECK-NEXT:    fmov w8, s0
; CHECK-NEXT:    cmp x8, #1 // =1
; CHECK-NEXT:    cset w0, eq
; CHECK-NEXT:    ret
;
; CHECK-NONEON-LABEL: ctpop_eq_one:
; CHECK-NONEON:       // %bb.0:
; CHECK-NONEON-NEXT:    lsr x8, x0, #1
; CHECK-NONEON-NEXT:    and x8, x8, #0x5555555555555555
; CHECK-NONEON-NEXT:    sub x8, x0, x8
; CHECK-NONEON-NEXT:    and x9, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    lsr x8, x8, #2
; CHECK-NONEON-NEXT:    and x8, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    add x8, x9, x8
; CHECK-NONEON-NEXT:    add x8, x8, x8, lsr #4
; CHECK-NONEON-NEXT:    and x8, x8, #0xf0f0f0f0f0f0f0f
; CHECK-NONEON-NEXT:    mov x9, #72340172838076673
; CHECK-NONEON-NEXT:    mul x8, x8, x9
; CHECK-NONEON-NEXT:    lsr x8, x8, #56
; CHECK-NONEON-NEXT:    cmp x8, #1 // =1
; CHECK-NONEON-NEXT:    cset w0, eq
; CHECK-NONEON-NEXT:    ret
  %count = tail call i64 @llvm.ctpop.i64(i64 %x)
  %cmp = icmp eq i64 %count, 1
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

define i32 @ctpop_ne_one(i64 %x) nounwind readnone {
; CHECK-LABEL: ctpop_ne_one:
; CHECK:       // %bb.0:
; CHECK-NEXT:    fmov d0, x0
; CHECK-NEXT:    cnt.8b v0, v0
; CHECK-NEXT:    uaddlv.8b h0, v0
; CHECK-NEXT:    fmov w8, s0
; CHECK-NEXT:    cmp x8, #1 // =1
; CHECK-NEXT:    cset w0, ne
; CHECK-NEXT:    ret
;
; CHECK-NONEON-LABEL: ctpop_ne_one:
; CHECK-NONEON:       // %bb.0:
; CHECK-NONEON-NEXT:    lsr x8, x0, #1
; CHECK-NONEON-NEXT:    and x8, x8, #0x5555555555555555
; CHECK-NONEON-NEXT:    sub x8, x0, x8
; CHECK-NONEON-NEXT:    and x9, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    lsr x8, x8, #2
; CHECK-NONEON-NEXT:    and x8, x8, #0x3333333333333333
; CHECK-NONEON-NEXT:    add x8, x9, x8
; CHECK-NONEON-NEXT:    add x8, x8, x8, lsr #4
; CHECK-NONEON-NEXT:    and x8, x8, #0xf0f0f0f0f0f0f0f
; CHECK-NONEON-NEXT:    mov x9, #72340172838076673
; CHECK-NONEON-NEXT:    mul x8, x8, x9
; CHECK-NONEON-NEXT:    lsr x8, x8, #56
; CHECK-NONEON-NEXT:    cmp x8, #1 // =1
; CHECK-NONEON-NEXT:    cset w0, ne
; CHECK-NONEON-NEXT:    ret
  %count = tail call i64 @llvm.ctpop.i64(i64 %x)
  %cmp = icmp ne i64 %count, 1
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}


declare i32 @llvm.ctpop.i32(i32) nounwind readnone
declare i64 @llvm.ctpop.i64(i64) nounwind readnone