OSDN Git Service

[DAGCombiner] transform sub-of-shifted-signbit to add
authorSanjay Patel <spatel@rotateright.com>
Mon, 30 Jul 2018 22:21:37 +0000 (22:21 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 30 Jul 2018 22:21:37 +0000 (22:21 +0000)
commit648b708c20ed4e47e41498360f03fb6bc0444590
treeadcae153e5570371f5979ee1fd7b818d61215441
parent00f1a051effdd0d904277c5fd24722e5c4905602
[DAGCombiner] transform sub-of-shifted-signbit to add

This is exchanging a sub-of-1 with add-of-minus-1:
https://rise4fun.com/Alive/plKAH

This is another step towards improving select-of-constants codegen (see D48970).

x86 is the motivating target, and those diffs all appear to be wins. PPC and AArch64 look neutral.
I've limited this to early combining (!LegalOperations) in case a target wants to reverse it, but
I think canonicalizing to 'add' is more likely to produce further transforms because we have more
folds for 'add'.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338317 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AArch64/signbit-shift.ll
test/CodeGen/PowerPC/signbit-shift.ll
test/CodeGen/X86/signbit-shift.ll