summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
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 ⅈ
+ }
+
KnownBits Known = IC.computeKnownBits(Op0, 0, &II);
// Create a mask for bits above (ctlz) or below (cttz) the first known one.
OpenPOWER on IntegriCloud