[llvm] [InstCombine] Fold minmax intrinsic using KnownBits information (PR #76242)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 22 07:46:04 PST 2023
================
@@ -1796,6 +1796,19 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
if (Instruction *NewMinMax = factorizeMinMaxTree(II))
return NewMinMax;
+ // Try to fold minmax based on range information
+ ICmpInst::Predicate Pred =
+ ICmpInst::getNonStrictPredicate(MinMaxIntrinsic::getPredicate(IID));
+ bool IsSigned = MinMaxIntrinsic::isSigned(IID);
+ const auto LHS_CR = llvm::computeConstantRangeIncludingKnownBits(
+ I0, IsSigned, SQ.getWithInstruction(II));
----------------
nikic wrote:
It looks like this still has some compile-time overhead. Would an early exit for full range help, to avoid computing the second one?
https://github.com/llvm/llvm-project/pull/76242
More information about the llvm-commits
mailing list