diff options
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 4bd1246cbf7..1b247245c4c 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1194,10 +1194,21 @@ 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 ⅈ + if (IsTZ) { + // cttz(-x) -> cttz(x) + if (match(Op0, m_Neg(m_Value(X)))) { + II.setOperand(0, X); + return ⅈ + } + + // cttz(abs(x)) -> cttz(x) + // cttz(nabs(x)) -> cttz(x) + Value *Y; + SelectPatternFlavor SPF = matchSelectPattern(Op0, X, Y).Flavor; + if (SPF == SPF_ABS || SPF == SPF_NABS) { + II.setOperand(0, X); + return ⅈ + } } KnownBits Known = IC.computeKnownBits(Op0, 0, &II); |

