[PATCH] R600/SI: Add fmin and fmax intrinsics
Marek Olšák
maraeo at gmail.com
Thu Nov 20 09:45:31 PST 2014
From: Marek Olšák <marek.olsak at amd.com>
For some reason, clamp isn't moved into the instruction. I always get this:
v_min_f32 v0, -abs(v5), -abs(v1)
v_add_f32 v0, 0, v0 clamp
---
lib/Target/R600/AMDGPUIntrinsics.td | 2 ++
lib/Target/R600/SIInstructions.td | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/lib/Target/R600/AMDGPUIntrinsics.td b/lib/Target/R600/AMDGPUIntrinsics.td
index eee9c29..3ee4023 100644
--- a/lib/Target/R600/AMDGPUIntrinsics.td
+++ b/lib/Target/R600/AMDGPUIntrinsics.td
@@ -50,6 +50,8 @@ let TargetPrefix = "AMDGPU", isTarget = 1 in {
def int_AMDGPU_trunc : Intrinsic<[llvm_float_ty], [llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_ddx : Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
def int_AMDGPU_ddy : Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
+ def int_AMDGPU_fmax : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
+ def int_AMDGPU_fmin : Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem]>;
def int_AMDGPU_imax : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
def int_AMDGPU_imin : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
def int_AMDGPU_umax : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
diff --git a/lib/Target/R600/SIInstructions.td b/lib/Target/R600/SIInstructions.td
index 90da7a9..27fdff9 100644
--- a/lib/Target/R600/SIInstructions.td
+++ b/lib/Target/R600/SIInstructions.td
@@ -2517,6 +2517,15 @@ def : Pat <
/* llvm.AMDGPU.pow */
def : POW_Common <V_LOG_F32_e32, V_EXP_F32_e32, V_MUL_LEGACY_F32_e32>;
+class VOP2Pat <SDPatternOperator pattern, InstSI inst> : Pat <
+ (pattern (VOP3Mods0 f32:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod),
+ (VOP3Mods f32:$src1, i32:$src1_modifiers)),
+ (inst $src0_modifiers, $src0, $src1_modifiers, $src1, $clamp, $omod)
+>;
+
+def : VOP2Pat <int_AMDGPU_fmin, V_MIN_F32_e64>;
+def : VOP2Pat <int_AMDGPU_fmax, V_MAX_F32_e64>;
+
def : Pat <
(int_AMDGPU_div f32:$src0, f32:$src1),
(V_MUL_LEGACY_F32_e32 $src0, (V_RCP_LEGACY_F32_e32 $src1))
--
2.1.0
More information about the llvm-commits
mailing list