Skip to content

[Clang][Codegen] Rint always lowered to llvm intrinsic #168139

@HendrikHuebner

Description

@HendrikHuebner

I was looking at this piece of code in the builtin codegen which decides whether we want to turn a call to a math functions (e.g. sqrt, absf) into a call to an intrinsic instead. I noticed that the boolean logic here will actually set GenerateIntrinsic to true when the builtin is marked as ConstIgnoringExceptions but not ConstIgnoringErrnoAndExceptions. From what I can tell this is only the case for rint defined here.

And indeed, even without -ffast-math and with -O0 (and even the optnone attribute), calls to rint always seem to get replaced by calls to the llvm intrinsic: https://godbolt.org/z/hTvEvs4Pq

Is this the desired behavior?

I think in any case, it would be nice to refactor this logic a little, and move it to a separate function. Originally I was looking into it to do just that, so we can also reuse this logic for ClangIR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.floating-pointFloating-point math

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions