[llvm] [InstCombine] Fold converted urem to 0 if there's no overlapping bits (PR #71528)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 11 01:50:10 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.
----------------
nikic wrote:
This pattern is basically the same as the `and 2^x-1, 2^C --> 0 where x <= C` one above -- but unfortunately I don't see any way to combine them with the analysis helpers we currently have available. So I think your approach of just adding this extra pattern is fine.
https://github.com/llvm/llvm-project/pull/71528
More information about the llvm-commits
mailing list