[llvm] [InstCombine] Add folds for `(fp_binop ({s|u}itofp x), ({s|u}itofp y))` (PR #82555)

Shao-Ce SUN via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 23:36:29 PDT 2024


sunshaoce wrote:

This commit `946ea4e3ca4c908bfa7c196b982795f5c390b923` caused the following program to produce inconsistent results:

```c
#include <stdio.h>
static int g_12 = 0xD010L;
static float g_842 = 1.0;
static volatile int g_2345 = 1;

static float(safe_mul_func_float_f_f)(float sf1, float sf2) {
  return (((0x1.0p-100f * sf1) * (0x1.0p-28f * sf2)) >
          (0x1.0p-100f * (0x1.0p-28f * 3.40282347e+38F)))
             ? (sf1)
             : (sf1 * sf2);
}

static void func_10(int p_11) {
  g_842 = safe_mul_func_float_f_f(0.0, (short)p_11);
  g_12 = 65529UL;
  g_2345 = p_11;
}

int main(int argc, char *argv[]) {
  func_10(g_12);
  printf("%f\n", g_842);
  return 0;
}

```

Before: `-0.000000`
After: `0.000000`

This is my compilation option:
```
build/bin/clang --target=riscv64-unknown-elf -march=rv64gcv -mabi=lp64d src/foo-main.c --gcc-toolchain=${GCC_TOOLCHAIN} --sysroot=${GCC_TOOLCHAIN}/riscv64-unknown-elf -O3
qemu-riscv64 a.out
```

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


More information about the llvm-commits mailing list