1*eddeb36cSFarzon Lotfi; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s 221edac25SFarzon Lotfi; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} 321edac25SFarzon Lotfi 421edac25SFarzon Lotfi; Make sure SPIRV operation function calls for distance are lowered correctly. 521edac25SFarzon Lotfi 621edac25SFarzon Lotfi; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "GLSL.std.450" 721edac25SFarzon Lotfi; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 821edac25SFarzon Lotfi; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 921edac25SFarzon Lotfi; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 1021edac25SFarzon Lotfi; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 1121edac25SFarzon Lotfi 1221edac25SFarzon Lotfidefine noundef half @distance_half4(<4 x half> noundef %a, <4 x half> noundef %b) { 1321edac25SFarzon Lotfientry: 1421edac25SFarzon Lotfi ; CHECK: %[[#]] = OpFunction %[[#float_16]] None %[[#]] 1521edac25SFarzon Lotfi ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_16]] 1621edac25SFarzon Lotfi ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_16]] 1721edac25SFarzon Lotfi ; CHECK: %[[#]] = OpExtInst %[[#float_16]] %[[#op_ext_glsl]] Distance %[[#arg0]] %[[#arg1]] 1821edac25SFarzon Lotfi %spv.distance = call half @llvm.spv.distance.f16(<4 x half> %a, <4 x half> %b) 1921edac25SFarzon Lotfi ret half %spv.distance 2021edac25SFarzon Lotfi} 2121edac25SFarzon Lotfi 2221edac25SFarzon Lotfidefine noundef float @distance_float4(<4 x float> noundef %a, <4 x float> noundef %b) { 2321edac25SFarzon Lotfientry: 2421edac25SFarzon Lotfi ; CHECK: %[[#]] = OpFunction %[[#float_32]] None %[[#]] 2521edac25SFarzon Lotfi ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_32]] 2621edac25SFarzon Lotfi ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_32]] 2721edac25SFarzon Lotfi ; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext_glsl]] Distance %[[#arg0]] %[[#arg1]] 2821edac25SFarzon Lotfi %spv.distance = call float @llvm.spv.distance.f32(<4 x float> %a, <4 x float> %b) 2921edac25SFarzon Lotfi ret float %spv.distance 3021edac25SFarzon Lotfi} 3121edac25SFarzon Lotfi 32*eddeb36cSFarzon Lotfidefine noundef float @distance_instcombine_float4(<4 x float> noundef %a, <4 x float> noundef %b) { 33*eddeb36cSFarzon Lotfientry: 34*eddeb36cSFarzon Lotfi ; CHECK: %[[#]] = OpFunction %[[#float_32]] None %[[#]] 35*eddeb36cSFarzon Lotfi ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_32]] 36*eddeb36cSFarzon Lotfi ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_32]] 37*eddeb36cSFarzon Lotfi ; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext_glsl]] Distance %[[#arg0]] %[[#arg1]] 38*eddeb36cSFarzon Lotfi %delta = fsub <4 x float> %a, %b 39*eddeb36cSFarzon Lotfi %spv.length = call float @llvm.spv.length.f32(<4 x float> %delta) 40*eddeb36cSFarzon Lotfi ret float %spv.length 41*eddeb36cSFarzon Lotfi} 42*eddeb36cSFarzon Lotfi 4321edac25SFarzon Lotfideclare half @llvm.spv.distance.f16(<4 x half>, <4 x half>) 4421edac25SFarzon Lotfideclare float @llvm.spv.distance.f32(<4 x float>, <4 x float>) 45