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

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 28 14:34:12 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();
----------------
andjo403 wrote:

added the test and when for a combination of our solutions that reduced number of calls to intersectWith also used full set range if old is missing as it is faster in intersectWith

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


More information about the llvm-commits mailing list