[llvm] [InstCombine]: Handle known negative variables with KnownBits (PR #89682)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 15:54:36 PDT 2024


================
@@ -1491,12 +1491,18 @@ Instruction *InstCombinerImpl::visitUDiv(BinaryOperator &I) {
   }
 
   // Op0 / C where C is large (negative) --> zext (Op0 >= C)
-  // TODO: Could use isKnownNegative() to handle non-constant values.
   Type *Ty = I.getType();
   if (match(Op1, m_Negative())) {
     Value *Cmp = Builder.CreateICmpUGE(Op0, Op1);
     return CastInst::CreateZExtOrBitCast(Cmp, Ty);
   }
+
----------------
goldsteinn wrote:

The `m_Negative` code is now unnecessary.

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


More information about the llvm-commits mailing list