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
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256
  257
  258
  259
  260
  261
  262
  263
  264
  265
  266
  267
  268
  269
  270
  271
  272
  273
  274
  275
  276
  277
  278
  279
  280
  281
  282
  283
  284
  285
  286
  287
  288
  289
  290
  291
  292
  293
  294
  295
  296
  297
  298
  299
  300
  301
  302
  303
  304
  305
  306
  307
  308
  309
  310
  311
  312
  313
  314
  315
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-pc-linux -mattr=+bmi,+bmi2,+popcnt,+lzcnt | FileCheck %s
declare void @foo(i32)
declare void @foo32(i32)
declare void @foo64(i64)

define void @neg(i32 %x) nounwind {
; CHECK-LABEL: neg:
; CHECK:       # %bb.0:
; CHECK-NEXT:    negl %edi
; CHECK-NEXT:    je .LBB0_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB0_1: # %return
; CHECK-NEXT:    retq
  %sub = sub i32 0, %x
  %cmp = icmp eq i32 %sub, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %sub)
  br label %return

return:
  ret void
}

define void @sar(i32 %x) nounwind {
; CHECK-LABEL: sar:
; CHECK:       # %bb.0:
; CHECK-NEXT:    sarl %edi
; CHECK-NEXT:    je .LBB1_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB1_1: # %return
; CHECK-NEXT:    retq
  %ashr = ashr i32 %x, 1
  %cmp = icmp eq i32 %ashr, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %ashr)
  br label %return

return:
  ret void
}

define void @shr(i32 %x) nounwind {
; CHECK-LABEL: shr:
; CHECK:       # %bb.0:
; CHECK-NEXT:    shrl %edi
; CHECK-NEXT:    je .LBB2_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB2_1: # %return
; CHECK-NEXT:    retq
  %ashr = lshr i32 %x, 1
  %cmp = icmp eq i32 %ashr, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %ashr)
  br label %return

return:
  ret void
}

define void @shri(i32 %x) nounwind {
; CHECK-LABEL: shri:
; CHECK:       # %bb.0:
; CHECK-NEXT:    shrl $3, %edi
; CHECK-NEXT:    je .LBB3_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB3_1: # %return
; CHECK-NEXT:    retq
  %ashr = lshr i32 %x, 3
  %cmp = icmp eq i32 %ashr, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %ashr)
  br label %return

return:
  ret void
}

define void @shl(i32 %x) nounwind {
; CHECK-LABEL: shl:
; CHECK:       # %bb.0:
; CHECK-NEXT:    addl %edi, %edi
; CHECK-NEXT:    je .LBB4_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB4_1: # %return
; CHECK-NEXT:    retq
  %shl = shl i32 %x, 1
  %cmp = icmp eq i32 %shl, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %shl)
  br label %return

return:
  ret void
}

define void @shli(i32 %x) nounwind {
; CHECK-LABEL: shli:
; CHECK:       # %bb.0:
; CHECK-NEXT:    shll $4, %edi
; CHECK-NEXT:    je .LBB5_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB5_1: # %return
; CHECK-NEXT:    retq
  %shl = shl i32 %x, 4
  %cmp = icmp eq i32 %shl, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %shl)
  br label %return

return:
  ret void
}

define zeroext i1 @adc(i128 %x) nounwind {
; CHECK-LABEL: adc:
; CHECK:       # %bb.0:
; CHECK-NEXT:    movabsq $-9223372036854775808, %rax # imm = 0x8000000000000000
; CHECK-NEXT:    addq %rdi, %rax
; CHECK-NEXT:    adcq $0, %rsi
; CHECK-NEXT:    sete %al
; CHECK-NEXT:    retq
  %add = add i128 %x, 9223372036854775808
  %cmp = icmp ult i128 %add, 18446744073709551616
  ret i1 %cmp
}

define zeroext i1 @sbb(i128 %x, i128 %y) nounwind {
; CHECK-LABEL: sbb:
; CHECK:       # %bb.0:
; CHECK-NEXT:    cmpq %rdx, %rdi
; CHECK-NEXT:    sbbq %rcx, %rsi
; CHECK-NEXT:    setns %al
; CHECK-NEXT:    retq
  %sub = sub i128 %x, %y
  %cmp = icmp sge i128 %sub, 0
  ret i1 %cmp
}

define void @andn(i32 %x, i32 %y) nounwind {
; CHECK-LABEL: andn:
; CHECK:       # %bb.0:
; CHECK-NEXT:    andnl %esi, %edi, %edi
; CHECK-NEXT:    je .LBB8_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB8_1: # %return
; CHECK-NEXT:    retq
  %not = xor i32 %x, -1
  %andn = and i32 %y, %not
  %cmp = icmp eq i32 %andn, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %andn)
  br label %return

return:
  ret void
}

declare i32 @llvm.x86.bmi.bextr.32(i32, i32) nounwind readnone
define void @bextr(i32 %x, i32 %y) nounwind {
; CHECK-LABEL: bextr:
; CHECK:       # %bb.0:
; CHECK-NEXT:    bextrl %esi, %edi, %edi
; CHECK-NEXT:    je .LBB9_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB9_1: # %return
; CHECK-NEXT:    retq
  %bextr = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x, i32 %y)
  %cmp = icmp eq i32 %bextr, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %bextr)
  br label %return

return:
  ret void
}

declare i32 @llvm.ctpop.i32(i32) nounwind readnone
define void @popcnt(i32 %x) nounwind {
; CHECK-LABEL: popcnt:
; CHECK:       # %bb.0:
; CHECK-NEXT:    popcntl %edi, %edi
; CHECK-NEXT:    je .LBB10_1
; CHECK-NEXT:  # %bb.2: # %bb
; CHECK-NEXT:    jmp foo # TAILCALL
; CHECK-NEXT:  .LBB10_1: # %return
; CHECK-NEXT:    retq
  %popcnt = tail call i32 @llvm.ctpop.i32(i32 %x)
  %cmp = icmp eq i32 %popcnt, 0
  br i1 %cmp, label %return, label %bb
bb:
  tail call void @foo(i32 %popcnt)
  br label %return
return:
  ret void
}

declare i64 @llvm.cttz.i64(i64, i1)
define i64 @testCTZ(i64 %v) nounwind {
; CHECK-LABEL: testCTZ:
; CHECK:       # %bb.0:
; CHECK-NEXT:    tzcntq %rdi, %rcx
; CHECK-NEXT:    movl $255, %eax
; CHECK-NEXT:    cmovaeq %rcx, %rax
; CHECK-NEXT:    retq
  %cnt = tail call i64 @llvm.cttz.i64(i64 %v, i1 true)
  %tobool = icmp eq i64 %v, 0
  %cond = select i1 %tobool, i64 255, i64 %cnt
  ret i64 %cond
}

declare i32 @llvm.cttz.i32(i32, i1)
define void @testCTZ2(i32 %v) nounwind {
; CHECK-LABEL: testCTZ2:
; CHECK:       # %bb.0:
; CHECK-NEXT:    pushq %rbx
; CHECK-NEXT:    tzcntl %edi, %ebx
; CHECK-NEXT:    jb .LBB12_2
; CHECK-NEXT:  # %bb.1: # %bb
; CHECK-NEXT:    movl %ebx, %edi
; CHECK-NEXT:    callq foo
; CHECK-NEXT:  .LBB12_2: # %return
; CHECK-NEXT:    movl %ebx, %edi
; CHECK-NEXT:    popq %rbx
; CHECK-NEXT:    jmp foo32 # TAILCALL
  %cnt = tail call i32 @llvm.cttz.i32(i32 %v, i1 true)
  %cmp = icmp eq i32 %v, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %cnt)
  br label %return

return:
  tail call void @foo32(i32 %cnt)
  ret void
}

define void @testCTZ3(i32 %v) nounwind {
; CHECK-LABEL: testCTZ3:
; CHECK:       # %bb.0:
; CHECK-NEXT:    pushq %rbx
; CHECK-NEXT:    tzcntl %edi, %ebx
; CHECK-NEXT:    jae .LBB13_2
; CHECK-NEXT:  # %bb.1: # %bb
; CHECK-NEXT:    movl %ebx, %edi
; CHECK-NEXT:    callq foo
; CHECK-NEXT:  .LBB13_2: # %return
; CHECK-NEXT:    movl %ebx, %edi
; CHECK-NEXT:    popq %rbx
; CHECK-NEXT:    jmp foo32 # TAILCALL
  %cnt = tail call i32 @llvm.cttz.i32(i32 %v, i1 true)
  %cmp = icmp ne i32 %v, 0
  br i1 %cmp, label %return, label %bb

bb:
  tail call void @foo(i32 %cnt)
  br label %return

return:
  tail call void @foo32(i32 %cnt)
  ret void
}

declare i64 @llvm.ctlz.i64(i64, i1)
define i64 @testCLZ(i64 %v) nounwind {
; CHECK-LABEL: testCLZ:
; CHECK:       # %bb.0:
; CHECK-NEXT:    lzcntq %rdi, %rcx
; CHECK-NEXT:    movl $255, %eax
; CHECK-NEXT:    cmovaeq %rcx, %rax
; CHECK-NEXT:    retq
  %cnt = tail call i64 @llvm.ctlz.i64(i64 %v, i1 true)
  %tobool = icmp ne i64 %v, 0
  %cond = select i1 %tobool, i64 %cnt, i64 255
  ret i64 %cond
}

declare i64 @llvm.ctpop.i64(i64)
define i64 @testPOPCNT(i64 %v) nounwind {
; CHECK-LABEL: testPOPCNT:
; CHECK:       # %bb.0:
; CHECK-NEXT:    popcntq %rdi, %rcx
; CHECK-NEXT:    movl $255, %eax
; CHECK-NEXT:    cmovneq %rcx, %rax
; CHECK-NEXT:    retq
  %cnt = tail call i64 @llvm.ctpop.i64(i64 %v)
  %tobool = icmp ne i64 %v, 0
  %cond = select i1 %tobool, i64 %cnt, i64 255
  ret i64 %cond
}