summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-05-17 17:12:32 +0200
committerNikita Popov <npopov@redhat.com>2023-05-17 17:14:54 +0200
commit4ca30ded4f07b192b8a8bed069400f9d6b85a792 (patch)
tree8d09b0115b085be60db0c331f20307cf79e09618
parent2f3ac28cb2f7fc24c6ff742af571b58419c0adaa (diff)
downloadllvm-4ca30ded4f07b192b8a8bed069400f9d6b85a792.tar.gz
[InstCombine] Use KnownBits::urem() helper
This provides more precise results than the ad-hoc implementation. Noticed while trying to add a consistency assertion. To be honest I'm not sure why this code exists at all -- the recursive calls are done with all bits demanded, so this should be equivalent to just using the default case.
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 0d0522a18349..c00bc74191a0 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -855,14 +855,12 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
break;
}
case Instruction::URem: {
- KnownBits Known2(BitWidth);
APInt AllOnes = APInt::getAllOnes(BitWidth);
- if (SimplifyDemandedBits(I, 0, AllOnes, Known2, Depth + 1) ||
- SimplifyDemandedBits(I, 1, AllOnes, Known2, Depth + 1))
+ if (SimplifyDemandedBits(I, 0, AllOnes, LHSKnown, Depth + 1) ||
+ SimplifyDemandedBits(I, 1, AllOnes, RHSKnown, Depth + 1))
return I;
- unsigned Leaders = Known2.countMinLeadingZeros();
- Known.Zero = APInt::getHighBitsSet(BitWidth, Leaders) & DemandedMask;
+ Known = KnownBits::urem(LHSKnown, RHSKnown);
break;
}
case Instruction::Call: {