Skip to content

[aarch64] Unnecessary masking of lower bits after ubfiz #171752

@purplesyringa

Description

@purplesyringa

Godbolt

#include <stdint.h>

uint8_t f(uint8_t x, uint64_t n) {
    return (uint16_t)((x << 1) | (x << 8)) >> n;
}
f(unsigned char, unsigned long):
        ubfiz   w8, w0, #1, #8
        orr     w8, w8, w0, lsl #8
        and     w8, w8, #0xfffe ; why is this `and` here? `unfiz` should've zeroed the lowest bit
        lsr     w0, w8, w1
        ret

Happens during isel, not sure why.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:AArch64missed-optimizationquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions