OSDN Git Service

[DAGCombiner] Teach DAG combiner that A-(B-C) can be folded to A+(C-B)
authorCraig Topper <craig.topper@intel.com>
Sat, 28 Jul 2018 00:27:25 +0000 (00:27 +0000)
committerCraig Topper <craig.topper@intel.com>
Sat, 28 Jul 2018 00:27:25 +0000 (00:27 +0000)
commitfefdba1e17f2599c69f2521e8edf83dae99994ae
tree87d85b5b33fe2a43bfcb65db105c1835e64de161
parente593ad899afe88b83eb96cbebbd368dcc48ff125
[DAGCombiner] Teach DAG combiner that A-(B-C) can be folded to A+(C-B)

This can be useful since addition is commutable, and subtraction is not.

This matches a transform that is also done by InstCombine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338181 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AArch64/arm64-cse.ll
test/CodeGen/ARM/machine-cse-cmp.ll
test/CodeGen/Mips/const-mult.ll
test/CodeGen/X86/rem.ll
test/CodeGen/X86/vector-idiv-sdiv-128.ll
test/CodeGen/X86/vector-idiv-sdiv-256.ll
test/CodeGen/X86/vector-idiv-sdiv-512.ll
test/CodeGen/X86/vector-idiv-udiv-128.ll
test/CodeGen/X86/vector-idiv-udiv-256.ll
test/CodeGen/X86/vector-idiv-udiv-512.ll