Bug 19598 - [arm] non-optimal handling of invalid immediate constant in XOR
Summary: [arm] non-optimal handling of invalid immediate constant in XOR
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2005-01-24 00:10 UTC by Philip Blundell
Modified: 2010-04-24 14:24 UTC (History)
3 users (show)

See Also:
Host:
Target: arm-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-07-23 05:57:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Blundell 2005-01-24 00:10:54 UTC
This function:

int f(int x)
{
  return x ^ 0x1234;
}

currently compiles (with -mtune=xscale) to:

        mov     r3, #4608
        add     r3, r3, #52
        eor     r0, r0, r3
        @ lr needed for prologue
        mov     pc, lr

or (with -mtune=arm9) to:

        ldr     r3, .L3
        @ lr needed for prologue
        eor     r0, r0, r3
        mov     pc, lr
.L4:
        .align  2
.L3:
        .word   4660

But, in both cases, it could be better done as:

        eor     r0, r0, #4608
        eor     r0, r0, #52
        mov     pc, lr
Comment 1 Richard Earnshaw 2005-01-25 10:59:46 UTC
Confirmed.

arm_split_constant() already knows how to handle XOR, so it should be just a
matter of copying the model used for andsi3 into the xorsi3 expander.
Comment 2 Richard Earnshaw 2010-04-24 14:24:52 UTC
Fixed with:

http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01723.html