If we have a load of a global address that's not modified during the
authorBill Wendling <isanbard@gmail.com>
Sun, 30 Dec 2007 03:18:58 +0000 (03:18 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 30 Dec 2007 03:18:58 +0000 (03:18 +0000)
commit6259d51c91d7da9bf16114849236b5bdfa85f35e
tree0363bdd85f1f091816cb15ac66cfe486de1a72e5
parentece6737f1510080ff655798cf2256d856ea84797
If we have a load of a global address that's not modified during the
function, then go ahead and hoist it out of the loop. This is the result:

$ cat a.c
volatile int G;

int A(int N) {
  for (; N > 0; --N)
    G++;
}
$ llc -o - -relocation-model=pic
_A:
...
LBB1_2: # bb
        movl    L_G$non_lazy_ptr-"L1$pb"(%eax), %esi
        incl    (%esi)
        incl    %edx
        cmpl    %ecx, %edx
        jne     LBB1_2  # bb
...
$ llc -o - -relocation-model=pic -machine-licm
_A:
...
        movl    L_G$non_lazy_ptr-"L1$pb"(%eax), %eax
LBB1_2: # bb
        incl    (%eax)
        incl    %edx
        cmpl    %ecx, %edx
        jne     LBB1_2  # bb
...

I'm limiting this to the MOV32rm x86 instruction for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45444 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrInfo.h