Compute demanded bits for icmp instructions
Instead of bailing out when we see an icmp, we can instead at least
say that if the upper bits of both operands are known zero, they are
not demanded. This doesn't help with signed comparisons, but it's at
least better than bailing out.
llvm-svn: 249687
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp
index 6f92ba6..912c5ce 100644
--- a/llvm/lib/Analysis/DemandedBits.cpp
+++ b/llvm/lib/Analysis/DemandedBits.cpp
@@ -242,6 +242,13 @@
if (OperandNo != 0)
AB = AOut;
break;
+ case Instruction::ICmp:
+ // Count the number of leading zeroes in each operand.
+ ComputeKnownBits(BitWidth, I, UserI->getOperand(1));
+ auto NumLeadingZeroes = std::min(KnownZero.countLeadingOnes(),
+ KnownZero2.countLeadingOnes());
+ AB = ~APInt::getHighBitsSet(BitWidth, NumLeadingZeroes);
+ break;
}
}