Skip to content

Use BLSR fusions to break dependency chains even when intermediate expression value is consumed #160756

@Validark

Description

@Validark

Godbolt

#include <stdint.h>

uint64_t foo(uint64_t z) {
    uint64_t w = z - 1;
    return (z & w) * w;
}

Emits:

foo:
        lea     rax, [rdi - 1]
        and     rdi, rax ; can't be computed in parallel with `lea`
        imul    rax, rdi
        ret

I was expecting:

foo:
        lea     rax, [rdi - 1]
        blsr    rdi, rdi ; can be computed in parallel with `lea`
        imul    rax, rdi
        ret

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