-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
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.