[compiler-rt] [builtins] Convert more int to fp functions to use common implementation (PR #67540)

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 07:09:14 PDT 2023


asb wrote:

Ping for review. I've rebased now that #66903 has landed and additionally can demonstrate equivalence using Alive2 (caveat below):
* floatdisf
  * <https://alive2.llvm.org/ce/z/mcAyPM>
* floattidf
  * <https://alive2.llvm.org/ce/z/rM7kPz>
* floattisf
  * <https://alive2.llvm.org/ce/z/HJp4jp>
* floattitf
  * <https://alive2.llvm.org/ce/z/6pGHuH>
* floatundisf
  * <https://alive2.llvm.org/ce/z/4uTm_H>
* floatuntidf
  * <https://alive2.llvm.org/ce/z/SCWV7J>
* floatuntisf
  * <https://alive2.llvm.org/ce/z/acoFF5>
* floatuntitf
  * <https://alive2.llvm.org/ce/z/t3QaLr>

The caveat is that alive2 won't show equivalence for the functions that take i128 as an input where `__clzti2` is called (there is no __builtin_clz variant in Clang for i128, so no way to generate llvm.ctlz.i128 calls). It doesn't understand it's semantics and seemingly the conservative analysis it does results in slightly different cases where poison is introduced for the two functions. However, massaging the output to replace that call with one to llvm.ctlz.i128 does show equivalence. I did encounter a gotcha whereby incorrectly doing this replacement (e.g. getting the signature wrong) would indicate `llvm.ctlz.i128 = constant ? bytes, align 8` in Alive's output and it confidently claimed equivalence when e.g. changing one of the call args to a constant. The linked comparisons avoid this issue though.

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


More information about the llvm-commits mailing list