[InstCombine] reassociate diff of sums into sum of diffs
authorSanjay Patel <spatel@rotateright.com>
Tue, 23 Jun 2020 00:45:00 +0000 (20:45 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 23 Jun 2020 00:47:09 +0000 (20:47 -0400)
commit8953ecf22bcf665ffb06399a97265ab71aebebf8
tree0898369277ab967401b5ab136c8fe30b7ae88444
parent7e1f376f8016bcfea4067de28c42ec6a7eb091fe
[InstCombine] reassociate diff of sums into sum of diffs

This is the integer sibling to D81491.

(a[0] + a[1] + a[2] + a[3]) - (b[0] + b[1] + b[2] +b[3]) -->
(a[0] - b[0]) + (a[1] - b[1]) + (a[2] - b[2]) + (a[3] - b[3])

Removing the "experimental" from these intrinsics is likely
not too far away.
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/vector-reductions.ll
llvm/test/Transforms/PhaseOrdering/X86/vector-reductions.ll