Skip to content

[X86] Multiple use shift amount mask not removed from SHLX #199697

Description

@Validark

(Zig Godbolt) (LLVM Godbolt)

define internal i32 @foo(i32 %0, i32 %1) unnamed_addr align 1 {
Entry:
  %2 = and i32 %1, 31
  %3 = shl i32 %0, %2
  %4 = xor i32 %3, %2
  ret i32 %4
}

Compiles to:

foo:
        and     esi, 31
        shlx    eax, edi, esi
        xor     eax, esi
        ret

Should be:

foo:
        shlx    eax, edi, esi
        and     esi, 31
        xor     eax, esi
        ret

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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