Skip to content

powerpc64le: power9 codgen bug when generating setb instructions #143989

Open
@pmur

Description

@pmur

The rust frontend ran into a bug when running tests on ppc64le with pgo enabled on centos. The compilation of the compiler's rustc_errors crate with -mcpu=power9 created a bug where a boolean value is clobbered, resulting in incorrect json values.

I was able to extract the llvm input from rust, and run llvm-reduce to produce a reasonably sized reproducer using the upstream llvm repo.

The following codegen is suspect:

        andi. 3, 4, 1
        setb 3, 2
        cmpldi  4, 0
        std 28, 80(1)                           # 8-byte Folded Spill
        stw 3, 60(1)

Notably, cr2 in the setb above has no live value (I am assuming this is following the ELFv2 ABI).

After the machine-cp pass, a copy from cr0gt to cr2lt goes missing. Likewise, the other bits of cr2 appear to be undefined. Furthermore, setb potentially examines all bits of the input cr, so moving one bit is not sufficient for well-defined behavior.

Attached is the reduced llvm input reduced.ll.txt. Likewise, I assembled it via:

llc -march=ppc64le -mcpu=pwr9 reduced.ll.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions