[PATCH] D128895: [InstCombine] Make use of low zero bits to determine exact int->fp cast

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 11:36:44 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:1761
   KnownBits SrcKnown = IC.computeKnownBits(Src, 0, &I);
-  int LowBits =
-      (int)SrcTy->getScalarSizeInBits() - SrcKnown.countMinLeadingZeros();
+  int LowBits = (int)SrcTy->getScalarSizeInBits() -
+                SrcKnown.countMinLeadingZeros() -
----------------
Change variable name to SigBits since we're not only counting high zeros now?


================
Comment at: llvm/test/Transforms/InstCombine/sitofp.ll:250
 ;
-  %m = and i25 %A, 16777216  ; Negative test - intermediate 16777216 (= 1 << 24)
+  %m = and i25 %A, 16777216  ; Make use of the low zero bits - intermediate 16777216 (= 1 << 24)
   %B = uitofp i25 %m to float
----------------
This test would be better with 16777218 (= 1 << 24 + 2). That would test the limits of high and low set bits, and the next test shows that we did not go past the limit.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128895/new/

https://reviews.llvm.org/D128895



More information about the llvm-commits mailing list