This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, AArch64] Allow symbol+offset even if not being used for memory access


Hi,

This patch builds on a previous one that allowed symbol+offset as symbol
references for memory accesses.  It allows us to have symbol+offset even
when no memory access is apparent.

It reduces codesize for cases such as this one:

  int arr[100];

  uint64_t foo (uint64_t a) {
    uint64_t const z = 1234567ll<<32+7;
    uint64_t const y = (uint64_t) &arr[3];
    return y + a + z;
  }

Before the patch, the code looked like this:

    adrp    x2, arr            
    mov     x1, 74217034874880 
    add     x2, x2, :lo12:arr  
    add     x2, x2, 12         
    movk    x1, 2411, lsl 48   
    add     x1, x2, x1         
    add     x0, x1, x0         
    ret                        

Now, it looks like this:
 
    adrp    x1, arr+12
    mov     x2, 74217034874880
    movk    x2, 2411, lsl 48
    add     x1, x1, :lo12:arr+12
    add     x1, x1, x2
    add     x0, x1, x0
    ret

Testing shows no regressions.  OK to commit?


2012-08-31  Ian Bolton  <ian.bolton@arm.com>

	* gcc/config/aarch64/aarch64.md: New pattern.

Attachment: aarch64-symbol-with-offset-for-constants-v1.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]