Skip to content

PowerPC: branches and conditionals do not agree on implicit operands/registers #2044

@Kaltxi

Description

@Kaltxi

Hello! It seems that in PPC the branch instructions incorrectly determine implicit register accesses, while some conditional instructions do not determine them at all. I expect branches and conditionals to be in agreement - conditionals write to conditional register or CTR (when applicable), while branches read corresponding register.

Here are some examples:

beq

Currently:

Reads: [CTR, RM]
Writes: [CTR]
Operands: [IMM]

Expected:

Reads: [CR0]
Writes: []
Operands: [IMM]

Not sure what is RM register and whether it is warranted here.

beq

blt (explicit)

Currently:

Reads: [CTR, RM]
Writes: [CTR]
Operands: [CR7, IMM]

Expected:

Reads: []
Writes: []
Operands: [CR7, IMM]

Here CR7 is correctly determined as it is an explicit operand, but the incorrect implicits still present.

blt-expl

bdnz

Currently and expected:

Reads: [CTR]
Writes: [CTR]
Operands: [IMM]

Here implicit CTR read and write is correct, but there is a different problem of bdnz not being identified as conditional branch, and not given bc value.

bdnz

cmpwi

Currently:

Reads: []
Writes: []
Operands: [REG, IMM]

Expected:

Reads: []
Writes: [CR0]
Operands: [REG, IMM]

cmpwi

rlwinm.

Currently and expected:

Reads: []
Writes: [CR0]
Operands: [REG, REG, IMM, IMM, IMM]

Here CR0 is correctly determined for instruction with dot suffix in addition to update_cr0 flag being set.

rlwinm

fcmpu (explicit)

Currently and expected:

Reads: []
Writes: []
Operands: [CR7, REG, REG]

Here CR7 is correctly determined as it is an explicit operand.

fcmpu

P.S. There is also another related issue of operands not supporting access flags, like in ARM for example, only implicit accesses are determined. But I suppose that feature is simply unsupported for PPC at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions