aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/countbits.ll
blob: 69f01dacc74a0b5bab58fea8133d8ec12be8f0ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %}

; CHECK: OpMemoryModel Logical GLSL450

define noundef i32 @countbits_i32(i32 noundef %a) {
entry:
; CHECK: %[[#]] = OpBitCount %[[#]] %[[#]]
  %elt.bitreverse = call i32 @llvm.ctpop.i32(i32 %a)
  ret i32 %elt.bitreverse
}

define noundef i16 @countbits_i16(i16 noundef %a) {
entry:
; CHECK: %[[#]] = OpBitCount %[[#]] %[[#]]
  %elt.ctpop = call i16 @llvm.ctpop.i16(i16 %a)
  ret i16 %elt.ctpop
}

declare i16 @llvm.ctpop.i16(i16)
declare i32 @llvm.ctpop.i32(i32)