aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2020-10-23 08:29:27 -0400
committerSanjay Patel <spatel@rotateright.com>2020-10-23 08:43:45 -0400
commit3fb0d6b0d55b52a214a3e5118dda3c7d3422782a (patch)
tree2b667e779f1da3049ad61cd31b246a8052b363c5 /llvm/lib/Analysis/ValueTracking.cpp
parent0351bd959faefe54456b43933b2f628ea14efb0d (diff)
downloadllvm-3fb0d6b0d55b52a214a3e5118dda3c7d3422782a.zip
llvm-3fb0d6b0d55b52a214a3e5118dda3c7d3422782a.tar.gz
llvm-3fb0d6b0d55b52a214a3e5118dda3c7d3422782a.tar.bz2
[ValueTracking] add range limits for ctlz
As discussed in D89952, instcombine can sometimes find a way to reduce similar patterns, but it is incomplete. InstSimplify uses the computeConstantRange() ValueTracking analysis via simplifyICmpWithConstant(), so we just need to fill in the max value of ctlz to process any "icmp pred ctlz(X), C" pattern (the min value is initialized to zero automatically). Follow-up to D89976.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 7124ca8..e277b02 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -6461,7 +6461,8 @@ static void setLimitsForIntrinsic(const IntrinsicInst &II, APInt &Lower,
const APInt *C;
switch (II.getIntrinsicID()) {
case Intrinsic::ctpop:
- // Maximum of set bits is the bit width.
+ case Intrinsic::ctlz:
+ // Maximum of set/clear bits is the bit width.
assert(Lower == 0 && "Expected lower bound to be zero");
Upper = Width + 1;
break;