Recompiler: BC0T/BC0TL are never taken and BC0FL/BC0TL run their delay slot unconditionally
メンテナーはふだん 5 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- cpp
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C++
- スター
- 3.3k
- フォーク
- 149
- 平均マージ
- 8時間 46分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ran-j/PS2Recomp のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ran-j/PS2Recomp#393 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
EE sceCdStatus stub always reports READ (6), hanging games that wait for PAUSE対応中かも @ahmedgamalalzatary が 17 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 5 日以内に返信
-
VU0 macro VSQI / VSQD: address and source registers swapped in generated code対応中かも @yanm1103 が 25 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 5 日以内に返信
-
Runtime: SampleTexture casts unbounded or NaN texture coordinates to int, which is undefined behaviour再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ran-j/PS2Recomp#273 · コメント 2 件 ·
メンテナーはふだん 5 日以内に返信
-
Build: /Qspectre- is MSVC-only and breaks every Release target under clang-cl対応中かも @ahmedgamalalzatary が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 5 日以内に返信
ran-j/PS2Recomp の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
NKI-AI/fastslide#105 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
DarkCastleMUD/DarkCastle#283 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
-priority- blocked good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
scribe-org/Scribe-Android#761 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信