[llvm] ValueTracking: simplify udiv/urem recurrences (PR #108973)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 5 11:31:40 PST 2024
================
@@ -1427,16 +1427,23 @@ static void computeKnownBitsFromOperator(const Operator *I,
// this is sufficient to catch some interesting cases.
unsigned Opcode = BO->getOpcode();
- // If this is a shift recurrence, we know the bits being shifted in.
- // We can combine that with information about the start value of the
- // recurrence to conclude facts about the result.
switch (Opcode) {
+ // If this is a shift recurrence, we know the bits being shifted in. We
+ // can combine that with information about the start value of the
+ // recurrence to conclude facts about the result. If this is a udiv
+ // recurrence, we know that the result can never exceed either the
+ // numerator or the start value, whichever is greater.
case Instruction::LShr:
case Instruction::AShr:
- case Instruction::Shl: {
+ case Instruction::Shl:
+ case Instruction::UDiv:
if (BO->getOperand(0) != I)
break;
+ [[fallthrough]];
+ // For a urem recurrence, the result can never exceed the start value. The
+ // start value could either be the numerator or the denominator.
----------------
nikic wrote:
The second sentence should probably refer to the phi / recurrence rather than start value?
https://github.com/llvm/llvm-project/pull/108973
More information about the llvm-commits
mailing list