[llvm] [InstCombine] Extend `(lshr/shl (shl/lshr -1, x), x)` -> `(lshr/shl -1, x)` for multi-use (PR #81576)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 03:33:13 PST 2024


================
@@ -1206,6 +1206,12 @@ Instruction *InstCombinerImpl::visitShl(BinaryOperator &I) {
     return BinaryOperator::CreateAnd(Mask, X);
   }
 
+  // Transform  (-1 >> y) << y  to -1 << y
+  if (match(Op0, m_LShr(m_AllOnes(), m_Specific(Op1)))) {
----------------
nikic wrote:

Any particular reason why this one uses m_LShr while the above uses m_Shr? It's valid for ashr as well: https://alive2.llvm.org/ce/z/fN5_7L

https://github.com/llvm/llvm-project/pull/81576


More information about the llvm-commits mailing list