[llvm] [InstCombine] Reduce range of ctpop for non zero argument (PR #100899)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 27 20:03:25 PDT 2024


================
@@ -694,8 +694,13 @@ static Instruction *foldCtpop(IntrinsicInst &II, InstCombinerImpl &IC) {
   // Add range attribute since known bits can't completely reflect what we know.
   if (BitWidth != 1 && !II.hasRetAttr(Attribute::Range) &&
       !II.getMetadata(LLVMContext::MD_range)) {
-    ConstantRange Range(APInt(BitWidth, Known.countMinPopulation()),
-                        APInt(BitWidth, Known.countMaxPopulation() + 1));
+    unsigned KnownMinPop = Known.countMinPopulation();
----------------
dtcxzyw wrote:

There is a phase ordering problem. We may get a more precise result later. See my previous comment https://github.com/llvm/llvm-project/pull/100870#issuecomment-2254213148.


https://github.com/llvm/llvm-project/pull/100899


More information about the llvm-commits mailing list