[InstCombine] Negator: 0 - (X + Y) --> (-X) - Y iff a single operand negated
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 5 Aug 2020 16:17:56 +0000 (19:17 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 5 Aug 2020 17:01:13 +0000 (20:01 +0300)
commit3a3c9519e272e664172a0a90e8abf84b6d400106
tree3fd0051c49364cdcf61d11c2327ad86afc591d30
parent26f79e258ffd74bc5e8fadb44947c9deba2e5375
[InstCombine] Negator: 0 - (X + Y)  -->  (-X) - Y  iff a single operand negated

This was the most obvious regression in
f5df5cd5586ae9cfb2d9e53704dfc76f47aff149.f5df5cd5586ae9cfb2d9e53704dfc76f47aff149

We really don't want to do this if the original/outermost subtraction
isn't a negation, and therefore doesn't go away - just sinking negation
isn't a win. We are actually appear to be missing folds so hoist it.

https://rise4fun.com/Alive/tiVe
llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp
llvm/test/Transforms/InstCombine/sub-of-negatible.ll
llvm/test/Transforms/InstCombine/sub.ll