OSDN Git Service

DAGCombiner: Don't unnecessarily swap operands in ReassociateOps
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 27 Feb 2016 19:57:45 +0000 (19:57 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 27 Feb 2016 19:57:45 +0000 (19:57 +0000)
commit2bc40a1dbd77f1657160ad598b5b98b7f952e398
tree63a08c6887906f476216966773ac52dc0e30512a
parent7dd408db9a132a0df426ef60cbf9ac51ec78e714
DAGCombiner: Don't unnecessarily swap operands in ReassociateOps

In the case where op = add, y = base_ptr, and x = offset, this
transform:

(op y, (op x, c1)) -> (op (op x, y), c1)

breaks the canonical form of add by putting the base pointer in the
second operand and the offset in the first.

This fix is important for the R600 target, because for some address
spaces the base pointer and the offset are stored in separate register
classes. The old pattern caused the ISel code for matching addressing
modes to put the base pointer and offset in the wrong register classes,
which required no-trivial code transformations to fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262148 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AMDGPU/dagcombine-reassociate-bug.ll [new file with mode: 0644]
test/CodeGen/AMDGPU/shl_add_constant.ll
test/CodeGen/X86/add-nsw-sext.ll
test/CodeGen/X86/combine-multiplies.ll