Skip to content

GCC emits superfluous movt r#, 0x0 instructions #61

@jar

Description

@jar

GCC emits the instruction pair...

mov r#, 0x####
movt r#, 0x####

for loading a 32-bit value into a register. When the compile-time value is less than 16-bits, the movt instruction is unnecessary since the mov (immediate) instruction will load the full value and zero the high bits.

For example, I find this pattern a lot in compiled code:

mov r#, 0x####
movt r#, 0x0

The emitted code for the movt is larger than necessary and performance takes a small hit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions