[DAGCombiner] Fix ReplaceExtractVectorEltOfLoadWithNarrowedLoad for BE
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 5 May 2015 19:33:37 +0000 (19:33 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 5 May 2015 19:33:37 +0000 (19:33 +0000)
commitd32c49bf685f98088844d6a399965362870d0532
tree7cefe641a66c8c5f151c64b35f79ce5b9ce3233e
parent7e0334d096f72e2f1296e8fb6a49561e8d2e9621
[DAGCombiner] Fix ReplaceExtractVectorEltOfLoadWithNarrowedLoad for BE

For little-endian, the function would convert (extract_vector_elt (load X), Y)
to X + Y*sizeof(elt).  For big-endian it would instead use
X + sizeof(vec) - Y*sizeof(elt).  The big-endian case wasn't right since
vector index order always follows memory/array order, even for big-endian.
(Note that the current handling has to be wrong for Y==0 since it would
access beyond the end of the vector.)

Original patch by Richard Sandiford.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236529 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/SystemZ/vec-extract-01.ll [new file with mode: 0644]