[PATCH] D112694: [ValueTracking] Teach computeConstantRange that the maximum value of a half is 65504

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 28 02:08:11 PDT 2021


dmgreen created this revision.
dmgreen added reviewers: spatel, nikic, efriedma.
Herald added subscribers: armkevincheng, jsmolens, eric-k256, hiraditya.
Herald added a reviewer: sjarus.
dmgreen requested review of this revision.
Herald added a project: LLVM.

The maximal value of a half is 0x7bff, which is 65504 when converted to an integer. This patch teaches that to computeConstantRange to compute a constant range with the correct maximum value.
https://alive2.llvm.org/ce/z/BV_Spb
https://alive2.llvm.org/ce/z/Nwuqvb

The maximum value for a float converted in the same way is 3.4e38, which requires 129bits of data. I have not added that here as integer types so larger are rare, compared to integers types larger than 17 bits require for half floats.

The MVE tests change because instsimplify happens to be run as a port of the backend, where it doesn't tend to for other backends.


https://reviews.llvm.org/D112694

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/CodeGen/Thumb2/mve-fpclamptosat_vec.ll
  llvm/test/Transforms/InstSimplify/fptoi-range.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112694.382428.patch
Type: text/x-patch
Size: 47107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211028/4295a717/attachment.bin>


More information about the llvm-commits mailing list