https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91645
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2019-09-04
Blocks| |85316
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. We have no value-range analysis for floating-point, plus
call-DCE emits an unordered >= while your test is using an ordered compare.
<bb 2> [local count: 1073741824]:
y_4 = x_3(D) * x_3(D);
if (y_4 >= 0.0)
goto <bb 3>; [26.75%]
else
goto <bb 6>; [73.25%]
<bb 3> [local count: 287225938]:
if (y_4 u>= 0.0)
goto <bb 4>; [99.95%]
else
goto <bb 5>; [0.05%]
<bb 4> [local count: 287082327]:
_7 = .SQRT (y_4);
goto <bb 6>; [100.00%]
<bb 5> [local count: 143611]:
_10 = __builtin_sqrtf (y_4);
and jump threading doesn't know that if y >= 0.0 is true then
isgreaterequal (y, 0.0) is as well. OTOH I'm not sure that's
actually true since IIRC isgreaterequal (y, 0.0) will return
true if isunordered (y, 0.0) while for y >= 0.0 the result
is unspecified?
So maybe you simply have to adjust your precondition appropriately
like
y = x * x;
if (isless (y, 0.0))
__builtin_unreachable ();
return std::sqrt (y);
that way it works for me?
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases