[DAGCombiner] Don't reassociate operations that have the vector reduction flag set.
authorCraig Topper <craig.topper@intel.com>
Thu, 16 Aug 2018 21:54:05 +0000 (21:54 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 16 Aug 2018 21:54:05 +0000 (21:54 +0000)
commit883ff69c9365a7eb2fb146f029bb33afcb98524b
treebd9c35208105e67da8361bbd1055d86dfc21389c
parentbde2b43cb3386534dc2f66d6de29567cf1347b9d
[DAGCombiner] Don't reassociate operations that have the vector reduction flag set.

When nodes are reassociated the vector-reduction flag gets lost.

The test case is here is what would happen if you had a sum of absolute differences loop that started with a non-zero but contant sum and that loop was unrolled. The vectorizer will generate a constant vector for the initial value. And DAGCombiner reassociate tries to move it down the addition tree erasing the vector-reduction flag. Interestingly this moves constants the opposite direction of the reassociate IR pass.

I've chosen to just punt on the reassociate, but I suppose we could maybe preserve the flag if both nodes have it set.

Differential Revision: https://reviews.llvm.org/D50827

llvm-svn: 339946
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/sad.ll