mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 12:55:57 +00:00
The FP fast paths of the lifted code check FPCR.RMode inside the result compare and pass vector slow-path operands through the Cpu
The result check of every scalar and vector FP op compares |r| against a per-thread threshold in the Cpu (fp_th_s, fp_th_d): the smallest normal in round-to-nearest, NaN under a directed RMode, so a directed mode sends every result to the redo path and the separate load and test of c->fpcr per op goes. rt_fpcr_threshold sets it; rt_fpcr_sync calls it on every host, and the Cpu inits and the fiber switch's fpcr copy call it too. The vector slow path FN(vredo) takes its operands from c->fp_arg instead of three stack copies per call site, which takes ___chkstk_ms out of the large lifted functions (275 call sites in main to 5). It reruns only the lanes that failed the check. A NaN result in round-to-nearest goes from redo straight to fix with the FZ-flushed operands. The static FP helpers use preserve_most, so their cold call sites do not spill the caller-saved registers. Results are bit-identical to the old headers (equivalence harness of build/v143-genko/static2, 200M cases). On the 42 hottest 1.4.3 functions: instructions -8.2%, bytes -8.8%, hot-path instructions -4.3%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
94eb3d4628
commit
5c48f62fca
8 files changed
+89
-12
No files matched your search
@@ -1445,6 +1445,7 @@ static RtThread *thr_new(int prio, int core, uint64_t mask) {
|
||||
Cpu *c = plat_aligned_alloc(sizeof(Cpu), 64);
|
||||
if (!t || !c) rt_fatal("kernel: thread allocation");
|
||||
memset(c, 0, sizeof *c);
|
||||
rt_fpcr_threshold(c);
|
||||
plat_cond_init(&t->cv);
|
||||
t->prio = prio;
|
||||
t->core = core;
|
||||
@@ -2259,6 +2260,7 @@ static void fiber_switch_to(RtThread *t, const Cpu *from, Fiber *to) {
|
||||
dst->tpidr = from->tpidr;
|
||||
dst->tpidrro = from->tpidrro;
|
||||
dst->fpcr = from->fpcr;
|
||||
rt_fpcr_threshold(dst); // fiber_resumed syncs MXCSR on the other side; the threshold follows fpcr at once
|
||||
dst->fpsr = from->fpsr;
|
||||
dst->excl_addr = ~0ull;
|
||||
dst->thread = t;
|
||||
@@ -2291,6 +2293,7 @@ void kern_fiber_initialize(Cpu *c) {
|
||||
plat_fiber_free(f->host);
|
||||
}
|
||||
memset(f->cpu, 0, sizeof *f->cpu);
|
||||
rt_fpcr_threshold(f->cpu);
|
||||
f->cpu->excl_addr = ~0ull;
|
||||
f->addr = addr;
|
||||
f->func = c->x[1];
|
||||
|
||||
Reference in new issue
Block a user