Skip to content

~a & ~b & ~c should not compile to ~(a | b | c) #163516

@Validark

Description

@Validark

Zig Godbolt
C Godbolt

Currently compiles to:

foo:
        mov     rax, rdi
        or      rax, rsi
        or      rax, rdx
        not     rax
        ret

Should be:

foo:
        not     rdx
        or      rdi, rsi
        andn    rax, rdi, rdx
        ret

The difference is that the first snippet is going to take 3 cycles to execute because there is a serial dependency chain between all 3 operations. The second snippet can take 2 cycles to execute because the not and the or can run in the same cycle.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions