Skip to content

Redundant movzx instructions when operating on i8s #58338

Open
@krdln

Description

@krdln

In this playground the ternary_and example (roughly x < 3 ? 0 : x & 2) causes two redundant cmovx to be emitted. (They're redundant, as high bits of eax are already zeroed). The real world case I initially noticed this behaviour was using sub nuw instead of and. Here also high bits of eax should be zeroed (although opt turns this sub nuw into add, losing nuw annotation). This particular case is especially bad, since it uses movzx within same register (which I've read is not eligible to mov-elimination).

Perhaps related: #56498

edit: Removed the cast example and added zeroext attribute to arguments.

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