[llvm] [InstSimplify] Fold converted urem to 0 if there's no overlapping bits (PR #71528)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 05:47:45 PST 2023


================
@@ -2103,6 +2103,22 @@ static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
       isKnownToBeAPowerOfTwo(Op0, Q.DL, /*OrZero*/ true, 0, Q.AC, Q.CxtI, Q.DT))
     return Constant::getNullValue(Op0->getType());
 
+  // (x << N) & ((x << M) - 1) --> 0, where x is known to be a power of 2 and
+  // M <= N.
----------------
huntergr-arm wrote:

Yes, I realized it was very similar, so put my code just after. An 'm_Maybe' would be nice, but as you say it doesn't exist yet.

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


More information about the llvm-commits mailing list