summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-07-27 10:54:48 +0000
committerSanjay Patel <spatel@rotateright.com>2018-07-27 10:54:48 +0000
commit78e4b4d3c442a8ee97f2488a7ec690146a42c6ac (patch)
tree4f9156d2565b67ba23874dbb66350436849a675d /llvm/lib
parenteee52b5090de793274bbb589b5a9ac64808f01bc (diff)
downloadbcm5719-llvm-78e4b4d3c442a8ee97f2488a7ec690146a42c6ac.tar.gz
bcm5719-llvm-78e4b4d3c442a8ee97f2488a7ec690146a42c6ac.zip
[InstCombine] not(sub X, Y) --> add (not X), Y
The tests with constants show a missing optimization. Analysis for adds is better than subs, so this can also help with other transforms. And codegen is better with adds for targets like x86 (destructive ops, no sub-from). https://rise4fun.com/Alive/llK llvm-svn: 338118
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index d1922ccd81d..372bc41f780 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2545,6 +2545,10 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
}
}
+ // ~(X - Y) --> ~X + Y
+ if (match(NotVal, m_OneUse(m_Sub(m_Value(X), m_Value(Y)))))
+ return BinaryOperator::CreateAdd(Builder.CreateNot(X), Y);
+
// ~(~X >>s Y) --> (X >>s Y)
if (match(NotVal, m_AShr(m_Not(m_Value(X)), m_Value(Y))))
return BinaryOperator::CreateAShr(X, Y);
OpenPOWER on IntegriCloud