[PATCH] D154953: [InstSimplify] Remove the remainder loop if we know the mask is always true
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 00:55:54 PDT 2023
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:1285
+ KnownBits Known = computeKnownBits(Op1, Q.DL, 0, Q.AC, Q.CxtI, Q.DT);
+ if (RemC->getActiveBits() >= Known.getMaxValue().getActiveBits())
+ return ConstantInt::getNullValue(Op0->getType());
----------------
This should be just `RemC->uge(Known.getMaxValue())`. Same below.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:1288
+ return ConstantInt::getNullValue(Op0->getType());
+ }
+ }
----------------
goldstein.w.n wrote:
> Since we are already here, might as well also add an `else if(Known.getMinValue().ugt(*RemC)) { return Op0; }`
>
> Proofs: https://alive2.llvm.org/ce/z/FkTMoy
It looks like these proofs also work with urem replaced by srem: https://alive2.llvm.org/ce/z/-8RHjq So we should move this into simplifyRem and support both.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154953/new/
https://reviews.llvm.org/D154953
More information about the llvm-commits
mailing list