]> granicus.if.org Git - llvm/commit
[DAGCombine] Fix for a load combine bug with non-zero offset patterns on BE targets
authorArtur Pilipenko <apilipenko@azulsystems.com>
Mon, 27 Feb 2017 13:04:23 +0000 (13:04 +0000)
committerArtur Pilipenko <apilipenko@azulsystems.com>
Mon, 27 Feb 2017 13:04:23 +0000 (13:04 +0000)
commit85f508cd9dba8a982471d98c4f649fb0d63f3451
tree428640f792251bfcb4bfd7bffd25c90855ae3a6b
parentf85432589bb013281b8b51899738f6e6ad4fb4a7
[DAGCombine] Fix for a load combine bug with non-zero offset patterns on BE targets

This pattern is essentially a i16 load from p+1 address:

  %p1.i16 = bitcast i8* %p to i16*
  %p2.i8 = getelementptr i8, i8* %p, i64 2
  %v1 = load i16, i16* %p1.i16
  %v2.i8 = load i8, i8* %p2.i8
  %v2 = zext i8 %v2.i8 to i16
  %v1.shl = shl i16 %v1, 8
  %res = or i16 %v1.shl, %v2

Current implementation would identify %v1 load as the first byte load and would mistakenly emit a i16 load from %p1.i16 address. This patch adds a check that the first byte is loaded from a non-zero offset of the first load address. This way this address can be used as the base address for the combined value. Otherwise just give up combining.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296336 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AArch64/load-combine-big-endian.ll
test/CodeGen/ARM/load-combine-big-endian.ll