[PATCH] D127854: [InstCombine] Use known bits to determine exact int->fp cast

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 00:36:33 PDT 2022


nikic added a comment.

It would be good to add tests for the sitofp case as well.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:1759
   // For example, compute number of sign bits or compute low bit mask.
+  KnownBits SrcKnown = llvm::computeKnownBits(Src, IC.getDataLayout());
+  int LowBits =
----------------
Can use `IC.computeKnownBits(Src, 0, &I)` to also make use of AC/DT, I believe.


================
Comment at: llvm/test/Transforms/InstCombine/sitofp.ll:245
+
+define i25 @overflow_masked_input(i25 %A) {
+; CHECK-LABEL: @overflow_masked_input(
----------------
According to alive, this mask would be fine: https://alive2.llvm.org/ce/z/PdpF6F This is because this is a mask of the form `0b1000...` rather than `0b1111...`. The right mask to test would be: https://alive2.llvm.org/ce/z/GYxTRu (We could also make use of these low zero bits, but I think that would be better as a separate change.)




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

https://reviews.llvm.org/D127854



More information about the llvm-commits mailing list