This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to force the branch target to be 4 byte aligned? Any compiler options to do that? I am using arm A15.

I have a tight loop listed as follow. thumb-2.

PC=0x700abdfe DISASS="MRRC     p15,#0,r0,r1,c14"

PC=0x700abe02 DISASS="SUBS     r0,r0,r2"

PC=0x700abe04 DISASS="SBC      r1,r1,r3"

PC=0x700abe08 DISASS="SUBS     r0,r0,r4"

PC=0x700abe0a DISASS="SBCS     r1,r1,r5"

PC=0x700abe0c DISASS="BCC      {pc}-0xe ; 0x700abdfe"

The target address,0x700abdfe, is not 4 byte aligned, the performance hit is huge.

How to force the branch target to be 4 byte aligned? Any compiler options to do that? I am using arm A15.

 

Parents
  • I don't think the issue is that the MRRC instruction is not 4-byte (word) aligned, as this is very common, but rather that it straddles a cache line boundary.

    You can use scatterloading to place this code in a suitably aligned execution region, but the finest granularity you would have is by function. If this code is in the middle of a function, it may not be feasible to control alignment.

    You could inject a NOP instructions with the compiler intrinsic __nop() (#include <arm_acle.h>) before the MRRC instruction, though you would need to re-check after each rebuild if it was necessary.

    Sorry, I can't think of a better solution.

Reply
  • I don't think the issue is that the MRRC instruction is not 4-byte (word) aligned, as this is very common, but rather that it straddles a cache line boundary.

    You can use scatterloading to place this code in a suitably aligned execution region, but the finest granularity you would have is by function. If this code is in the middle of a function, it may not be feasible to control alignment.

    You could inject a NOP instructions with the compiler intrinsic __nop() (#include <arm_acle.h>) before the MRRC instruction, though you would need to re-check after each rebuild if it was necessary.

    Sorry, I can't think of a better solution.

Children