https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119086
--- Comment #3 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> See pr 26724 and others.
>
> *** This bug has been marked as a duplicate of bug 26724 ***
Thanks for the pointer. Would you explain how that can be used for the test
case?
For example, with:
extern float sqrtf (float) __attribute__((nothrow));
__attribute__((noipa))
unsigned cheap_root2 (unsigned x)
{
return 1 + x / 2;
}
volatile int X;
static inline __attribute__((always_inline))
unsigned root2 (unsigned x)
{
unsigned r = (unsigned) sqrtf ((float) x);
if (__builtin_constant_p (r))
return r;
return cheap_root2 (x);
}
int main (void)
{
X = root2 (15);
__asm ("# Milestone" ::: "memory");
X = root2 (X);
return 0;
}
the result is as follows:
* X = root2 (15); is optimized as expected.
* In X = root2 (X); there are TWO computations of square root, one with float
arithmetic, and one via cheap_root2().
What I want is that in NO case whatsoever float arithmetic is being used on the
target (the purpose of the exercise is to optimize fixed-point square root for
constant arguments).