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)
commit982224cfb8de39337e977219b3571c5a87aca4ce
treebab1498538efc732c8ef02877d6e289e7729e7e4
parentb7692bc3e9ad2691fc07261904b88fb15f30696b
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.

llvm-svn: 262148
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AMDGPU/dagcombine-reassociate-bug.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/shl_add_constant.ll
llvm/test/CodeGen/X86/add-nsw-sext.ll
llvm/test/CodeGen/X86/combine-multiplies.ll