Recompiler: BC0T/BC0TL are never taken and BC0FL/BC0TL run their delay slot unconditionally
I maintainer di solito rispondono entro 5 giorni
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- compilers, reverse-engineering
Direzione di ricerca
Read ps2xRecomp/src/lib/control_flow_emitter.cpp, especially ControlFlowEmitter::conditionalBranchExpression() and isLikelyBranch(), then inspect the COP0 handling in cop0_translator.cpp. Add or locate the code-generator test covering BC0F, BC0T, BC0FL, and BC0TL with a non-NOP delay slot. The change is complete when COP0 branch conditions use the intended CPCOND0 behavior and likely branches nullify delay slots when not taken.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
The EE branch-on-COP0-condition instructions (BC0F, BC0T, BC0FL, BC0TL) branch on CPCOND0, which the DMAC drives. The recompiler has no COP0 case for them:
- The condition is always
false.ControlFlowEmitter::conditionalBranchExpression()(ps2xRecomp/src/lib/control_flow_emitter.cpp) handlesOPCODE_COP1andOPCODE_COP2branch conditions, but notOPCODE_COP0, so it returns"false"for every BC0 form.BC0FandBC0Tare therefore both never taken, although one of them must be taken for any value of CPCOND0. - The likely forms aren't recognized as likely.
ControlFlowEmitter::isLikelyBranch()lists COP1 and COP2BCxFL/BCxTL, but notCOP0_BC_BCFL/COP0_BC_BCTL. Their delay slot is emitted unconditionally, but a not-taken likely branch must nullify it.
cop0_translator.cpp says // BC0 ... - Handled by branch logic, but the branch logic doesn't handle it.
Effect
BC0F never taken matches "DMA already complete", which suits the runtime's eager DMA, so 1: bc0f 1b wait loops exit right away. But BC0T/BC0TL then go the wrong way, and BC0FL/BC0TL execute a delay-slot instruction the hardware would skip.
Hardware reference
CPCOND0 is true when every DMA channel selected in D_PCR.CPC has its D_STAT.CIS bit set. PCSX2 computes it as ((D_STAT.CIS | ~D_PCR.CPC) & 0x3FF) == 0x3FF, and BC0F branches when it's false.
Suggested fix
- Treat CPCOND0 as true:
BC0F/BC0FLnever taken (current behavior),BC0T/BC0TLalways taken. That matches the eager DMA model and can't turn abc0fwait loop into a hang. - Add
COP0_BC_BCFL/COP0_BC_BCTLtoisLikelyBranch().
A more exact alternative is to compute CPCOND0 from D_STAT/D_PCR at run time. But some DMA paths in the runtime can stall (VIF1/PATH3), so a bc0f wait loop could spin forever if a CIS bit isn't set when expected. The constant is the safer first step.
Repro
A code-generator test with a BC0x branch + non-NOP delay slot + target shows const bool branch_taken_... = (false); for all four forms, and the delay slot emitted before the taken check for BC0FL/BC0TL.
Found while reviewing COP0 coverage for #163. Tested on main e563698.
- Lingua principale
- C++
- Stelle
- 3.3k
- Fork
- 149
- Merge medio
- 8h 46m
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ran-j/PS2Recomp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
ran-j/PS2Recomp#393 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
EE sceCdStatus stub always reports READ (6), hanging games that wait for PAUSEForse già presa @ahmedgamalalzatary l’ha presa 13 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 5 giorni
-
VU0 macro VSQI / VSQD: address and source registers swapped in generated codeForse già presa @yanm1103 l’ha presa 21 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
Runtime: SampleTexture casts unbounded or NaN texture coordinates to int, which is undefined behaviourForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ran-j/PS2Recomp#273 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni
-
Build: /Qspectre- is MSVC-only and breaks every Release target under clang-clForse già presa @ahmedgamalalzatary l’ha presa 13 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di ran-j/PS2Recomp
Issue simili
-
[Feature]: Fedora 45 repoApertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
metasequoiaime/msime#10989 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
vek-language/vek-lang#1 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
eclipse-score/lifecycle#957 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
mw00/project-maya#877 ·
I maintainer di solito rispondono entro 1 giorno