| 1 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_float_controls2 %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_float_controls2 %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
;; This test checks that the OpenCL.std instructions fmin_common, fmax_common are replaced with fmin, fmax with NInf and NNaN instead. |
| 5 |
|
| 6 |
; CHECK-DAG: Capability FloatControls2 |
| 7 |
; CHECK: Extension "SPV_KHR_float_controls2" |
| 8 |
|
| 9 |
; CHECK: OpDecorate %[[#maxRes:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowRecip|AllowContract|AllowReassoc|AllowTransform |
| 10 |
; CHECK: OpDecorate %[[#maxCommonRes:]] FPFastMathMode NotNaN|NotInf |
| 11 |
; CHECK: OpDecorate %[[#minRes:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowRecip|AllowContract|AllowReassoc|AllowTransform |
| 12 |
; CHECK: OpDecorate %[[#minCommonRes:]] FPFastMathMode NotNaN|NotInf |
| 13 |
; CHECK: OpDecorate %[[#maxResV:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowRecip|AllowContract|AllowReassoc|AllowTransform |
| 14 |
; CHECK: OpDecorate %[[#maxCommonResV:]] FPFastMathMode NotNaN|NotInf |
| 15 |
; CHECK: OpDecorate %[[#minResV:]] FPFastMathMode NotNaN|NotInf|NSZ|AllowRecip|AllowContract|AllowReassoc|AllowTransform |
| 16 |
; CHECK: OpDecorate %[[#minCommonResV:]] FPFastMathMode NotNaN|NotInf |
| 17 |
; CHECK: %[[#maxRes]] = OpExtInst {{.*}} fmax |
| 18 |
; CHECK: %[[#maxCommonRes]] = OpExtInst {{.*}} fmax |
| 19 |
; CHECK: %[[#minRes]] = OpExtInst {{.*}} fmin |
| 20 |
; CHECK: %[[#minCommonRes]] = OpExtInst {{.*}} fmin |
| 21 |
; CHECK: %[[#maxResV]] = OpExtInst {{.*}} fmax |
| 22 |
; CHECK: %[[#maxCommonResV]] = OpExtInst {{.*}} fmax |
| 23 |
; CHECK: %[[#minResV]] = OpExtInst {{.*}} fmin |
| 24 |
; CHECK: %[[#minCommonResV]] = OpExtInst {{.*}} fmin |
| 25 |
|
| 26 |
; Function Attrs: convergent mustprogress nofree nounwind willreturn memory(none) |
| 27 |
declare spir_func float @_Z4fmodff(float, float) |
| 28 |
declare dso_local spir_func noundef nofpclass(nan inf) float @_Z16__spirv_ocl_fmaxff(float noundef nofpclass(nan inf), float noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 29 |
declare dso_local spir_func noundef nofpclass(nan inf) float @_Z23__spirv_ocl_fmax_commonff(float noundef nofpclass(nan inf), float noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 30 |
declare dso_local spir_func noundef nofpclass(nan inf) float @_Z16__spirv_ocl_fminff(float noundef nofpclass(nan inf), float noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 31 |
declare dso_local spir_func noundef nofpclass(nan inf) float @_Z23__spirv_ocl_fmin_commonff(float noundef nofpclass(nan inf), float noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 32 |
declare dso_local spir_func noundef nofpclass(nan inf) <2 x float> @_Z16__spirv_ocl_fmaxDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf), <2 x float> noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 33 |
declare dso_local spir_func noundef nofpclass(nan inf) <2 x float> @_Z23__spirv_ocl_fmax_commonDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf), <2 x float> noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 34 |
declare dso_local spir_func noundef nofpclass(nan inf) <2 x float> @_Z16__spirv_ocl_fminDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf), <2 x float> noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 35 |
declare dso_local spir_func noundef nofpclass(nan inf) <2 x float> @_Z23__spirv_ocl_fmin_commonDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf), <2 x float> noundef nofpclass(nan inf)) local_unnamed_addr #1 |
| 36 |
|
| 37 |
; Function Attrs: convergent mustprogress norecurse nounwind |
| 38 |
define weak_odr dso_local spir_kernel void @foo(float %1, float %2) { |
| 39 |
entry: |
| 40 |
%maxRes = tail call fast spir_func noundef nofpclass(nan inf) float @_Z16__spirv_ocl_fmaxff(float noundef nofpclass(nan inf) %1, float noundef nofpclass(nan inf) %2) |
| 41 |
%maxCommonRes = tail call spir_func noundef float @_Z23__spirv_ocl_fmax_commonff(float noundef nofpclass(nan inf) %1, float noundef nofpclass(nan inf) %2) |
| 42 |
%minRes = tail call fast spir_func noundef nofpclass(nan inf) float @_Z16__spirv_ocl_fminff(float noundef nofpclass(nan inf) %1, float noundef nofpclass(nan inf) %2) |
| 43 |
%minCommonRes = tail call spir_func noundef float @_Z23__spirv_ocl_fmin_commonff(float noundef nofpclass(nan inf) %1, float noundef nofpclass(nan inf) %2) |
| 44 |
ret void |
| 45 |
} |
| 46 |
|
| 47 |
define weak_odr dso_local spir_kernel void @fooV(<2 x float> %v1, <2 x float> %v2) { |
| 48 |
%maxResV = tail call fast spir_func noundef nofpclass(nan inf) <2 x float> @_Z16__spirv_ocl_fmaxDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf) %v1, <2 x float> noundef nofpclass(nan inf) %v2) |
| 49 |
%maxCommonResV = tail call spir_func noundef <2 x float> @_Z23__spirv_ocl_fmax_commonDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf) %v1, <2 x float> noundef nofpclass(nan inf) %v2) |
| 50 |
%minResV = tail call fast spir_func noundef nofpclass(nan inf) <2 x float> @_Z16__spirv_ocl_fminDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf) %v1, <2 x float> noundef nofpclass(nan inf) %v2) |
| 51 |
%minCommonResV = tail call spir_func noundef <2 x float> @_Z23__spirv_ocl_fmin_commonDv2_fDv2_f(<2 x float> noundef nofpclass(nan inf) %v1, <2 x float> noundef nofpclass(nan inf) %v2) |
| 52 |
ret void |
| 53 |
} |