Skip to content

ISel sinks math library calls below fesetenv #113607

@hiraditya

Description

@hiraditya
#include <fenv.h>
#include <math.h>
__attribute__((const))
long double myrintl(long double x);

long double nearbyintl(long double x) {
  fenv_t e;
  fegetenv(&e);
  long double result = rintl(x);
  fesetenv(&e);
  return result;
}

clang++ -O3

nearbyintl:
        sub     sp, sp, #48
        stp     x29, x30, [sp, #32]
        add     x29, sp, #32
        sub     x0, x29, #8
        str     q0, [sp]
        bl      fegetenv
        sub     x0, x29, #8
        bl      fesetenv
        ldr     q0, [sp]
        ldp     x29, x30, [sp, #32]
        add     sp, sp, #48
        b       rintl // moved here.

https://godbolt.org/z/7h7v1xKee

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions