[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 04:33:43 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:

did not think that far, forgets that the checks id done multiple times.
but then it fells like the draft that you have is better then this solution so we do not need to execute isKnownNonZero if not needed.

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


More information about the llvm-commits mailing list