aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/DemandedBits.cpp
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2015-10-08 12:40:06 +0000
committerJames Molloy <james.molloy@arm.com>2015-10-08 12:40:06 +0000
commite9d50dc9f72d9aa5741c6fc05eb828448b110c48 (patch)
tree59b5b71a1751e83310ddba5e71b7956357d014e8 /llvm/lib/Analysis/DemandedBits.cpp
parentbcd7f0ac9829fd3bae4ccdead15c40afd6957b4e (diff)
downloadllvm-e9d50dc9f72d9aa5741c6fc05eb828448b110c48.zip
llvm-e9d50dc9f72d9aa5741c6fc05eb828448b110c48.tar.gz
llvm-e9d50dc9f72d9aa5741c6fc05eb828448b110c48.tar.bz2
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
Diffstat (limited to 'llvm/lib/Analysis/DemandedBits.cpp')
-rw-r--r--llvm/lib/Analysis/DemandedBits.cpp7
1 files changed, 7 insertions, 0 deletions
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 @@ void DemandedBits::determineLiveOperandBits(
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;
}
}