| 1 |
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s |
| 2 |
|
| 3 |
; CHECK-DAG: %[[#float_64:]] = OpTypeFloat 64 |
| 4 |
; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32 |
| 5 |
; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16 |
| 6 |
; CHECK-DAG: %[[#vec2_float_16:]] = OpTypeVector %[[#float_16]] 2 |
| 7 |
; CHECK-DAG: %[[#vec2_float_32:]] = OpTypeVector %[[#float_32]] 2 |
| 8 |
; CHECK-DAG: %[[#vec2_float_64:]] = OpTypeVector %[[#float_64]] 2 |
| 9 |
; CHECK-DAG: %[[#vec3_float_16:]] = OpTypeVector %[[#float_16]] 3 |
| 10 |
; CHECK-DAG: %[[#vec3_float_32:]] = OpTypeVector %[[#float_32]] 3 |
| 11 |
; CHECK-DAG: %[[#vec3_float_64:]] = OpTypeVector %[[#float_64]] 3 |
| 12 |
; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4 |
| 13 |
; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4 |
| 14 |
; CHECK-DAG: %[[#vec4_float_64:]] = OpTypeVector %[[#float_64]] 4 |
| 15 |
; CHECK-DAG: %[[#const_f64_1:]] = OpConstant %[[#float_64]] 1 |
| 16 |
; CHECK-DAG: %[[#const_f32_1:]] = OpConstant %[[#float_32]] 1 |
| 17 |
; CHECK-DAG: %[[#const_f16_1:]] = OpConstant %[[#float_16]] 1 |
| 18 |
|
| 19 |
; CHECK-DAG: %[[#vec2_const_ones_f16:]] = OpConstantComposite %[[#vec2_float_16]] %[[#const_f16_1]] %[[#const_f16_1]] |
| 20 |
; CHECK-DAG: %[[#vec3_const_ones_f16:]] = OpConstantComposite %[[#vec3_float_16]] %[[#const_f16_1]] %[[#const_f16_1]] %[[#const_f16_1]] |
| 21 |
; CHECK-DAG: %[[#vec4_const_ones_f16:]] = OpConstantComposite %[[#vec4_float_16]] %[[#const_f16_1]] %[[#const_f16_1]] %[[#const_f16_1]] %[[#const_f16_1]] |
| 22 |
|
| 23 |
; CHECK-DAG: %[[#vec2_const_ones_f32:]] = OpConstantComposite %[[#vec2_float_32]] %[[#const_f32_1]] %[[#const_f32_1]] |
| 24 |
; CHECK-DAG: %[[#vec3_const_ones_f32:]] = OpConstantComposite %[[#vec3_float_32]] %[[#const_f32_1]] %[[#const_f32_1]] %[[#const_f32_1]] |
| 25 |
; CHECK-DAG: %[[#vec4_const_ones_f32:]] = OpConstantComposite %[[#vec4_float_32]] %[[#const_f32_1]] %[[#const_f32_1]] %[[#const_f32_1]] %[[#const_f32_1]] |
| 26 |
|
| 27 |
; CHECK-DAG: %[[#vec2_const_ones_f64:]] = OpConstantComposite %[[#vec2_float_64]] %[[#const_f64_1]] %[[#const_f64_1]] |
| 28 |
; CHECK-DAG: %[[#vec3_const_ones_f64:]] = OpConstantComposite %[[#vec3_float_64]] %[[#const_f64_1]] %[[#const_f64_1]] %[[#const_f64_1]] |
| 29 |
; CHECK-DAG: %[[#vec4_const_ones_f64:]] = OpConstantComposite %[[#vec4_float_64]] %[[#const_f64_1]] %[[#const_f64_1]] %[[#const_f64_1]] %[[#const_f64_1]] |
| 30 |
|
| 31 |
|
| 32 |
define spir_func noundef half @test_rcp_half(half noundef %p0) #0 { |
| 33 |
entry: |
| 34 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#float_16]] |
| 35 |
; CHECK: OpFDiv %[[#float_16]] %[[#const_f16_1]] %[[#arg0]] |
| 36 |
%hlsl.rcp = fdiv half 0xH3C00, %p0 |
| 37 |
ret half %hlsl.rcp |
| 38 |
} |
| 39 |
|
| 40 |
define spir_func noundef <2 x half> @test_rcp_half2(<2 x half> noundef %p0) #0 { |
| 41 |
entry: |
| 42 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec2_float_16]] |
| 43 |
; CHECK: OpFDiv %[[#vec2_float_16]] %[[#vec2_const_ones_f16]] %[[#arg0]] |
| 44 |
%hlsl.rcp = fdiv <2 x half> <half 0xH3C00, half 0xH3C00>, %p0 |
| 45 |
ret <2 x half> %hlsl.rcp |
| 46 |
} |
| 47 |
|
| 48 |
define spir_func noundef <3 x half> @test_rcp_half3(<3 x half> noundef %p0) #0 { |
| 49 |
entry: |
| 50 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec3_float_16]] |
| 51 |
; CHECK: OpFDiv %[[#vec3_float_16]] %[[#vec3_const_ones_f16]] %[[#arg0]] |
| 52 |
%hlsl.rcp = fdiv <3 x half> <half 0xH3C00, half 0xH3C00, half 0xH3C00>, %p0 |
| 53 |
ret <3 x half> %hlsl.rcp |
| 54 |
} |
| 55 |
|
| 56 |
define spir_func noundef <4 x half> @test_rcp_half4(<4 x half> noundef %p0) #0 { |
| 57 |
entry: |
| 58 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_16]] |
| 59 |
; CHECK: OpFDiv %[[#vec4_float_16]] %[[#vec4_const_ones_f16]] %[[#arg0]] |
| 60 |
%hlsl.rcp = fdiv <4 x half> <half 0xH3C00, half 0xH3C00, half 0xH3C00, half 0xH3C00>, %p0 |
| 61 |
ret <4 x half> %hlsl.rcp |
| 62 |
} |
| 63 |
|
| 64 |
define spir_func noundef float @test_rcp_float(float noundef %p0) #0 { |
| 65 |
entry: |
| 66 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#float_32]] |
| 67 |
; CHECK: OpFDiv %[[#float_32]] %[[#const_f32_1]] %[[#arg0]] |
| 68 |
%hlsl.rcp = fdiv float 1.000000e+00, %p0 |
| 69 |
ret float %hlsl.rcp |
| 70 |
} |
| 71 |
|
| 72 |
define spir_func noundef <2 x float> @test_rcp_float2(<2 x float> noundef %p0) #0 { |
| 73 |
entry: |
| 74 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec2_float_32]] |
| 75 |
; CHECK: OpFDiv %[[#vec2_float_32]] %[[#vec2_const_ones_f32]] %[[#arg0]] |
| 76 |
%hlsl.rcp = fdiv <2 x float> <float 1.000000e+00, float 1.000000e+00>, %p0 |
| 77 |
ret <2 x float> %hlsl.rcp |
| 78 |
} |
| 79 |
|
| 80 |
define spir_func noundef <3 x float> @test_rcp_float3(<3 x float> noundef %p0) #0 { |
| 81 |
entry: |
| 82 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec3_float_32]] |
| 83 |
; CHECK: OpFDiv %[[#vec3_float_32]] %[[#vec3_const_ones_f32]] %[[#arg0]] |
| 84 |
%hlsl.rcp = fdiv <3 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %p0 |
| 85 |
ret <3 x float> %hlsl.rcp |
| 86 |
} |
| 87 |
|
| 88 |
define spir_func noundef <4 x float> @test_rcp_float4(<4 x float> noundef %p0) #0 { |
| 89 |
entry: |
| 90 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_32]] |
| 91 |
; CHECK: OpFDiv %[[#vec4_float_32]] %[[#vec4_const_ones_f32]] %[[#arg0]] |
| 92 |
%hlsl.rcp = fdiv <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %p0 |
| 93 |
ret <4 x float> %hlsl.rcp |
| 94 |
} |
| 95 |
|
| 96 |
define spir_func noundef double @test_rcp_double(double noundef %p0) #0 { |
| 97 |
entry: |
| 98 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#float_64]] |
| 99 |
; CHECK: OpFDiv %[[#float_64]] %[[#const_f64_1]] %[[#arg0]] |
| 100 |
%hlsl.rcp = fdiv double 1.000000e+00, %p0 |
| 101 |
ret double %hlsl.rcp |
| 102 |
} |
| 103 |
|
| 104 |
define spir_func noundef <2 x double> @test_rcp_double2(<2 x double> noundef %p0) #0 { |
| 105 |
entry: |
| 106 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec2_float_64:]] |
| 107 |
; CHECK: OpFDiv %[[#vec2_float_64]] %[[#vec2_const_ones_f64]] %[[#arg0]] |
| 108 |
%hlsl.rcp = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %p0 |
| 109 |
ret <2 x double> %hlsl.rcp |
| 110 |
} |
| 111 |
|
| 112 |
define spir_func noundef <3 x double> @test_rcp_double3(<3 x double> noundef %p0) #0 { |
| 113 |
entry: |
| 114 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec3_float_64:]] |
| 115 |
; CHECK: OpFDiv %[[#vec3_float_64]] %[[#vec3_const_ones_f64]] %[[#arg0]] |
| 116 |
%hlsl.rcp = fdiv <3 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>, %p0 |
| 117 |
ret <3 x double> %hlsl.rcp |
| 118 |
} |
| 119 |
|
| 120 |
define spir_func noundef <4 x double> @test_rcp_double4(<4 x double> noundef %p0) #0 { |
| 121 |
entry: |
| 122 |
; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_64]] |
| 123 |
; CHECK: OpFDiv %[[#vec4_float_64]] %[[#vec4_const_ones_f64]] %[[#arg0]] |
| 124 |
%hlsl.rcp = fdiv <4 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>, %p0 |
| 125 |
ret <4 x double> %hlsl.rcp |
| 126 |
} |