From 2c381ea45ceda34bf478301976129fe1e24af074 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sun, 8 May 2022 02:05:03 +0200 Subject: [PATCH] AK: Add `clamp(f32x4, float, float)` We are allowed to directly compare `f32x4` with a `float`, so make use of it. --- AK/SIMDMath.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AK/SIMDMath.h b/AK/SIMDMath.h index 5fff5c361d3..4032ceabf1e 100644 --- a/AK/SIMDMath.h +++ b/AK/SIMDMath.h @@ -52,6 +52,11 @@ ALWAYS_INLINE static f32x4 clamp(f32x4 v, f32x4 min, f32x4 max) return v < min ? min : (v > max ? max : v); } +ALWAYS_INLINE static f32x4 clamp(f32x4 v, float min, float max) +{ + return v < min ? min : (v > max ? max : v); +} + ALWAYS_INLINE static f32x4 exp(f32x4 v) { // FIXME: This should be replaced with a vectorized algorithm instead of calling the scalar expf 4 times