Skip to content

[AArch64][CodeGen][CodeSize] Redundant 'and' can be remove with shifts in addr mode #34101

@llvmbot

Description

@llvmbot
Bugzilla Link 34753
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor

Extended Description

Test case:

int test(unsigned long long a, unsigned long long b, int *table) {    
  return table[(a * b) >> 58];  
}

Current assembly:

test:                                   // @test
// BB#0:                                // %entry
        mul x8, x1, x0
        lsr x8, x8, #56
        and x8, x8, #0xfc
        ldr w0, [x2, x8]
        ret

We should be able to remove the 'and' for a code size with as follows:

test:                                   // @test
// BB#0:                                // %entry
        mul x8, x1, x0
        lsr x8, x8, #58
        ldr w0, [x2, x8, lsl#2]
        ret

I'm not interested in pursuing this optimization, but I figured I'd file the bug, regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:AArch64bugzillaIssues migrated from bugzillaconfirmedVerified by a second partygood first issuehttps://github.com/llvm/llvm-project/contributemissed-optimization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions