| 1 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s |
| 2 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s |
| 3 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 4 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 5 |
|
| 6 |
; CHECK-DAG: %[[#op_ext_cl:]] = OpExtInstImport "OpenCL.std" |
| 7 |
|
| 8 |
; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 |
| 9 |
; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 |
| 10 |
; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 |
| 11 |
; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 |
| 12 |
|
| 13 |
define noundef half @distance_half4(<4 x half> noundef %a, <4 x half> noundef %b) { |
| 14 |
entry: |
| 15 |
; CHECK: %[[#]] = OpFunction %[[#float_16]] None %[[#]] |
| 16 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_16]] |
| 17 |
; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_16]] |
| 18 |
; CHECK: %[[#]] = OpExtInst %[[#float_16]] %[[#op_ext_cl]] distance %[[#arg0]] %[[#arg1]] |
| 19 |
%spv.distance = call half @llvm.spv.distance.f16(<4 x half> %a, <4 x half> %b) |
| 20 |
ret half %spv.distance |
| 21 |
} |
| 22 |
|
| 23 |
define noundef float @distance_float4(<4 x float> noundef %a, <4 x float> noundef %b) { |
| 24 |
entry: |
| 25 |
; CHECK: %[[#]] = OpFunction %[[#float_32]] None %[[#]] |
| 26 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_32]] |
| 27 |
; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_32]] |
| 28 |
; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext_cl]] distance %[[#arg0]] %[[#arg1]] |
| 29 |
%spv.distance = call float @llvm.spv.distance.f32(<4 x float> %a, <4 x float> %b) |
| 30 |
ret float %spv.distance |
| 31 |
} |
| 32 |
|
| 33 |
define noundef float @distance_instcombine_float4(<4 x float> noundef %a, <4 x float> noundef %b) { |
| 34 |
entry: |
| 35 |
; CHECK: %[[#]] = OpFunction %[[#float_32]] None %[[#]] |
| 36 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_32]] |
| 37 |
; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_32]] |
| 38 |
; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext_cl]] distance %[[#arg0]] %[[#arg1]] |
| 39 |
%delta = fsub <4 x float> %a, %b |
| 40 |
%spv.length = call float @llvm.spv.length.f32(<4 x float> %delta) |
| 41 |
ret float %spv.length |
| 42 |
} |
| 43 |
|
| 44 |
declare half @llvm.spv.distance.f16(<4 x half>, <4 x half>) |
| 45 |
declare float @llvm.spv.distance.f32(<4 x float>, <4 x float>) |