| 1 |
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 |
| 5 |
; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 |
| 6 |
|
| 7 |
; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 |
| 8 |
; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 |
| 9 |
|
| 10 |
define noundef float @fwidth_float(float noundef %a) { |
| 11 |
entry: |
| 12 |
; CHECK: %[[#float_32_arg:]] = OpFunctionParameter %[[#float_32]] |
| 13 |
; CHECK: %[[#]] = OpFwidth %[[#float_32]] %[[#float_32_arg]] |
| 14 |
%elt.fwidth = call float @llvm.spv.fwidth.f32(float %a) |
| 15 |
ret float %elt.fwidth |
| 16 |
} |
| 17 |
|
| 18 |
define noundef half @fwidth_half(half noundef %a) { |
| 19 |
entry: |
| 20 |
; CHECK: %[[#float_16_arg:]] = OpFunctionParameter %[[#float_16]] |
| 21 |
; CHECK: %[[#converted:]] = OpFConvert %[[#float_32]] %[[#float_16_arg]] |
| 22 |
; CHECK: %[[#fwidth:]] = OpFwidth %[[#float_32]] %[[#converted]] |
| 23 |
; CHECK: %[[#]] = OpFConvert %[[#float_16]] %[[#fwidth]] |
| 24 |
%elt.fwidth = call half @llvm.spv.fwidth.f16(half %a) |
| 25 |
ret half %elt.fwidth |
| 26 |
} |
| 27 |
|
| 28 |
define noundef <4 x float> @fwidth_float_vector(<4 x float> noundef %a) { |
| 29 |
entry: |
| 30 |
; CHECK: %[[#vec4_float_32_arg:]] = OpFunctionParameter %[[#vec4_float_32]] |
| 31 |
; CHECK: %[[#]] = OpFwidth %[[#vec4_float_32]] %[[#vec4_float_32_arg]] |
| 32 |
%elt.fwidth = call <4 x float> @llvm.spv.fwidth.v4f32(<4 x float> %a) |
| 33 |
ret <4 x float> %elt.fwidth |
| 34 |
} |
| 35 |
|
| 36 |
define noundef <4 x half> @fwidth_half_vector(<4 x half> noundef %a) { |
| 37 |
entry: |
| 38 |
; CHECK: %[[#vec4_float_16_arg:]] = OpFunctionParameter %[[#vec4_float_16]] |
| 39 |
; CHECK: %[[#converted:]] = OpFConvert %[[#vec4_float_32]] %[[#vec4_float_16_arg]] |
| 40 |
; CHECK: %[[#fwidth:]] = OpFwidth %[[#vec4_float_32]] %[[#converted]] |
| 41 |
; CHECK: %[[#]] = OpFConvert %[[#vec4_float_16]] %[[#fwidth]] |
| 42 |
%elt.fwidth = call <4 x half> @llvm.spv.fwidth.v4f16(<4 x half> %a) |
| 43 |
ret <4 x half> %elt.fwidth |
| 44 |
} |
| 45 |
|
| 46 |
declare float @llvm.spv.fwidth.f32(float) |
| 47 |
declare half @llvm.spv.fwidth.f16(half) |