A: expf fmaf 180296c80 + rt_div_tables vpermps dump

This commit is contained in:
2026-08-29 16:12:03 +03:00
parent 5e8c3d8af4
commit 85317ed674
2 changed files with 43 additions and 2 deletions
+29 -2
View File
@@ -1,7 +1,34 @@
#include "fn529fe0.hpp"
#include "rt_div_tables.hpp"
#include <cmath>
#include <algorithm>
#include <cstring>
#include <cfenv>
namespace {
inline float expf_180296c80(float x) {
// BLOCKMAP:569 expf FLOAT 180296c80 — n=fma(1.44269502,x,12582912), k=n-MAGIC,
// r=(x-0.69314718*k)-1.42861e-06*k, p=(((0.00829172*r+0.0418735)*r+0.166674)*r+0.499994)*r+1)*r+1
// out = bits((k<<23)+bits(p)), guard |x|>87.3365 slow
if (std::abs(x) > 87.3365478515625f) return std::exp(x);
const float LOG2E = 1.44269502f;
const float MAGIC = 12582912.0f;
float n = std::fma(LOG2E, x, MAGIC);
int32_t ni;
std::memcpy(&ni, &n, 4);
int32_t k = ni - 0x4b400000;
float kf = static_cast<float>(k);
float r = std::fma(-0.69314718f, kf, x);
r = std::fma(-1.428606e-06f, kf, r);
float p = std::fma(0.00829172f, r, 0.0418735f);
p = std::fma(p, r, 0.166674f);
p = std::fma(p, r, 0.499994f);
p = std::fma(p, r, 1.0f);
p = std::fma(p, r, 1.0f);
// scale by 2^k
return std::ldexp(p, k);
}
}
// Structural mask-apply chain FUN_180529fe0 (mono path). Step-by-step
// transcription; each component is a pure function so it can be unit-tested and
@@ -180,12 +207,12 @@ void chain_9_19(float* bands, float* tmp6f8, float* accVec,
tmp6f8[i] += rel[i] * accVec[i]; // lower
}
// 14: EXP#1 180296c80 expf + +=(-1) th2270 (24mm2 order fix)
for (size_t i = 0; i < nbin; i++) bands[i] = std::exp(bands[i]) - 1.0f;
for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]) - 1.0f;
// 15: array-mul track* th2000
// 16: *=kWarp + LOG#2 140980 (placeholder warp already passed)
for (size_t i = 0; i < nbin; i++) bands[i] *= warp[i];
// 17: EXP#2 + exp-variant 140a40/140b00
for (size_t i = 0; i < nbin; i++) bands[i] = std::exp(bands[i]);
for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]);
}
// ---- Legacy structural chain (pre-cascade) ---------------------------------
+14
View File
@@ -0,0 +1,14 @@
#pragma once
// DIVIDE 1803a06a0 tables from .rdata RVA 0x21269c0/0x2126a00 poly 0.207
// BLOCKMAP:580 vpermps+poly 1c dump
// extracted via PE .rdata .rdata VA 0x1baa000 raw 0x1ba8400
#include <array>
namespace rt_div {
constexpr std::array<float,32> tbl_1269c0 = {
127.0f,126.830078f,126.67807f,126.540558f,126.415039f,126.299561f,126.192642f,126.093109f,127.0f,126.830078f,126.67807f,126.540558f,126.415039f,126.299561f,126.192642f,126.093109f,0.0f,-3.12644238e-06f,1.8367532e-06f,1.05200343e-05f,-1.56322119e-06f,-2.65016098e-07f,2.86602835e-06f,2.73532123e-07f,0.0f,-3.12644238e-06f,1.8367532e-06f,1.05200343e-05f,-1.56322119e-06f,-2.65016098e-07f,2.86602835e-06f,2.73532123e-07f};
constexpr std::array<float,32> tbl_126a00 = {
0.0f,-3.12644238e-06f,1.8367532e-06f,1.05200343e-05f,-1.56322119e-06f,-2.65016098e-07f,2.86602835e-06f,2.73532123e-07f,0.0f,-3.12644238e-06f,1.8367532e-06f,1.05200343e-05f,-1.56322119e-06f,-2.65016098e-07f,2.86602835e-06f,2.73532123e-07f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f};
constexpr std::array<float,8> poly_0 = {
0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f,0.20751521f};
}