Merge load/store sequences with adresses: base + index + offset
authorArnold Schwaighofer <aschwaighofer@apple.com>
Mon, 1 Apr 2013 18:12:58 +0000 (18:12 +0000)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Mon, 1 Apr 2013 18:12:58 +0000 (18:12 +0000)
commitf28a29b776b7dc2b97d09c75d69494f862c216b3
tree2a74a99231f00e6cf3ce08dd2ab9caf9e441e0be
parent46479197843ecb651adc9417c49bbd1b00acfcb6
Merge load/store sequences with adresses: base + index + offset

We would also like to merge sequences that involve a variable index like in the
example below.

    int index = *idx++
    int i0 = c[index+0];
    int i1 = c[index+1];
    b[0] = i0;
    b[1] = i1;

By extending the parsing of the base pointer to handle dags that contain a
base, index, and offset we can handle examples like the one above.

The dag for the code above will look something like:

 (load (i64 add (i64 copyfromreg %c)
                (i64 signextend (i8 load %index))))

 (load (i64 add (i64 copyfromreg %c)
                (i64 signextend (i32 add (i32 signextend (i8 load %index))
                                         (i32 1)))))

The code that parses the tree ignores the intermediate sign extensions. However,
if there is a sign extension it needs to be on all indexes.

 (load (i64 add (i64 copyfromreg %c)
                (i64 signextend (add (i8 load %index)
                                     (i8 1))))
 vs

 (load (i64 add (i64 copyfromreg %c)
                (i64 signextend (i32 add (i32 signextend (i8 load %index))
                                         (i32 1)))))
radar://13536387

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178483 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/MergeConsecutiveStores.ll