llvm / llvm/llvm-project

`S_CBRANCH_G/I_FORK` and `S_CBRANCH_JOIN` Are Not Designated As Branches in the AMDGPU Backend

Open
#183,078 6 comments 0 reactions 0 assignees View on GitHub
backend:AMDGPU
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`S_CBRANCH_G/I_FORK` and `S_CBRANCH_JOIN` according to the AMD ISA documentation are conditional branches using branch-stack; However, they are not modeled as branches:
https://github.com/llvm/llvm-project/blob/3e2fb2e7cb169b564dac2fe9cf37458bbe5a3b5c/llvm/lib/Target/AMDGPU/SOPInstructions.td#L865-L872
https://github.com/llvm/llvm-project/blob/3e2fb2e7cb169b564dac2fe9cf37458bbe5a3b5c/llvm/lib/Target/AMDGPU/SOPInstructions.td#L369-L371
https://github.com/llvm/llvm-project/blob/3e2fb2e7cb169b564dac2fe9cf37458bbe5a3b5c/llvm/lib/Target/AMDGPU/SOPInstructions.td#L1160-L1164

At the very least the `MCInstrInfo` of the instructions should reflect they are indeed a branch. It would be great if the `SIInstrInfo`'s branch calculation methods also were updated accordingly, but I understand there is not much need in the backend because it never gets emitted anyway.

Contributor guide

Open the contributing guide

Research direction

Start by reading the referenced AMDGPU definitions in llvm/lib/Target/AMDGPU/SOPInstructions.td, then inspect MCInstrInfo and the SIInstrInfo branch-calculation methods. Confirm the AMD ISA branch behavior and update the instruction metadata and, if appropriate, the branch calculations; done means the instructions are recognized as branches with tests covering the change.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.