summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2019-06-20 17:04:14 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2019-06-20 17:04:14 +0000
commit01511192b23f531b8d378fa522d46647ce7b41a7 (patch)
tree8f38f9e83a88570ecc9d444275729eb96e2915b4 /llvm/lib
parent5dbe4a99266393008aaff354f45b977afaecc3c8 (diff)
downloadbcm5719-llvm-01511192b23f531b8d378fa522d46647ce7b41a7.tar.gz
bcm5719-llvm-01511192b23f531b8d378fa522d46647ce7b41a7.zip
[InstCombine] cttz(-x) -> cttz(x)
Summary: Signedness does not change number of trailing zeros. Reviewers: spatel, lebedev.ri, nikic Reviewed By: spatel Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63534 llvm-svn: 363951
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index e366c379e9b..4bd1246cbf7 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1194,6 +1194,12 @@ static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombiner &IC) {
return CallInst::Create(F, {X, II.getArgOperand(1)});
}
+ // cttz(-x) -> cttz(x)
+ if (IsTZ && match(Op0, m_Neg(m_Value(X)))) {
+ II.setOperand(0, X);
+ return &II;
+ }
+
KnownBits Known = IC.computeKnownBits(Op0, 0, &II);
// Create a mask for bits above (ctlz) or below (cttz) the first known one.
OpenPOWER on IntegriCloud