Bug 50060 - intrinsics not folded by the middle-end
Summary: intrinsics not folded by the middle-end
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-12 15:16 UTC by Paolo Carlini
Modified: 2011-08-12 21:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo Carlini 2011-08-12 15:16:40 UTC
Following up to 49813, this is a list of intrinsics, corresponding to C89 and C99 <math.h> (and C++11 <cmath>) facilities, not yet folded by the middle-end.

C89:
- fmod
- frexp

C99:
- lgamma
- llrint
- lrint
- nearbyint
- nextafter
- nexttoward
- remquo
- rint

Note: in the audit trail of PR49813, Comment #51, Jakub explains that nextafter and nexttoward should be doable rather easily.
Comment 1 Paolo Carlini 2011-08-12 16:12:56 UTC
Uhm, remquo is strange. I see a do_mpfr_remquo but the following C++11 snippet is rejected, I don't know why:

int r = 0;
constexpr double d = __builtin_remquo(1.0, 1.0, &r);
Comment 2 Paolo Carlini 2011-08-12 16:26:00 UTC
... frexp also don't understand at the moment. I see a fold_builtin_frexp but the following doesn't compile:

int r = 0;
constexpr double d = __builtin_frexp(1.0, &r);
Comment 3 Paolo Carlini 2011-08-12 17:00:10 UTC
I think we can safely scratch frexp & remquo from the list: I double checked that the middle-end functions correctly compute the constants.

(It seems more a problem with my C++ test snippets in Comments #1 / #2: I suppose any definition of such functions isn't viable for constexpr, because the body has to assign the pointed integer additionally to returning a value... If Jason could confirm it would be great)

Updated list:
C89:
- fmod

C99:
- lgamma
- llrint
- lrint
- nearbyint
- nextafter
- nexttoward
- rint
Comment 4 Jason Merrill 2011-08-12 21:17:05 UTC
(In reply to comment #3)
> (It seems more a problem with my C++ test snippets in Comments #1 / #2: I
> suppose any definition of such functions isn't viable for constexpr, because
> the body has to assign the pointed integer additionally to returning a value...
> If Jason could confirm it would be great)

Correct, the assignment makes it non-constant.
Comment 5 Paolo Carlini 2011-08-12 21:19:23 UTC
Thanks Jason.