[all-commits] [llvm/llvm-project] f623ad: [ExpandLargeFpConvert] Fix bug in int-to-fp expans...

Bevin Hansson via All-commits all-commits at lists.llvm.org
Fri Mar 15 04:42:45 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f623adbbbdea8ac6af06e44be218e4fa969e523d
      https://github.com/llvm/llvm-project/commit/f623adbbbdea8ac6af06e44be218e4fa969e523d
  Author: Bevin Hansson <59652494+bevin-hansson at users.noreply.github.com>
  Date:   2024-03-15 (Fri, 15 Mar 2024)

  Changed paths:
    M llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
    M llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
    M llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll

  Log Message:
  -----------
  [ExpandLargeFpConvert] Fix bug in int-to-fp expansion. (#85370)

When deciding whether to perform rounding on the significand,
the generated IR was using (width - leading zeros - 1) rather
than (width - leading zeros). This is different from how the
routine in compiler-rt does it:

    int sd = srcBits - clzSrcT(a);
    int e = sd - 1;
    if (sd > dstMantDig) {

This bug means that the following code, when built on -O0:

    #include <stdio.h>

    _BitInt(233) v_1037 = 0;

    int main(void)
    {
        v_1037 = 18014398509481982wb;
        double d = v_1037;
        printf("d = %f\n", d);

        return 0;
    }

prints "d = 9007199254740992.000000", which is incorrect.
The correct result is "d = 18014398509481982.000000".



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list