mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Add vector variants of sqrt and rsqrt
This commit is contained in:
parent
b1db1e4e4f
commit
5ba5a6615d
Notes:
sideshowbarker
2024-07-17 16:19:35 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/5ba5a6615d Pull-request: https://github.com/SerenityOS/serenity/pull/13405
1 changed files with 32 additions and 0 deletions
|
@ -6,7 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef __SSE__
|
||||
# include <AK/Math.h>
|
||||
#endif
|
||||
#include <AK/SIMD.h>
|
||||
#include <AK/SIMDExtras.h>
|
||||
#include <math.h>
|
||||
|
||||
// Functions returning vectors or accepting vector arguments have different calling conventions
|
||||
|
@ -59,6 +63,34 @@ ALWAYS_INLINE static f32x4 exp(f32x4 v)
|
|||
};
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static f32x4 sqrt(f32x4 v)
|
||||
{
|
||||
#ifdef __SSE__
|
||||
return __builtin_ia32_sqrtps(v);
|
||||
#else
|
||||
return f32x4 {
|
||||
AK::sqrt(v[0]),
|
||||
AK::sqrt(v[1]),
|
||||
AK::sqrt(v[2]),
|
||||
AK::sqrt(v[3]),
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static f32x4 rsqrt(f32x4 v)
|
||||
{
|
||||
#ifdef __SSE__
|
||||
return __builtin_ia32_rsqrtps(v);
|
||||
#else
|
||||
return f32x4 {
|
||||
1.f / AK::sqrt(v[0]),
|
||||
1.f / AK::sqrt(v[1]),
|
||||
1.f / AK::sqrt(v[2]),
|
||||
1.f / AK::sqrt(v[3]),
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
Loading…
Reference in a new issue