https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126549
Bug ID: 126549
Summary: [16/17 Regression] Wrong code with ranger and
int->float casts
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
Target Milestone: ---
/* operator_cast::fold_range (frange, tree, const irange &): the forward
INT -> FLOAT cast. It computes the bounds with real_from_integer in the
destination mode, which correctly overflows to +Inf for _Float16, and then
throws that away with frange_drop_infs, so the range of (_Float16) u for
u in [0, 100000] comes out as [0, 65504] and the comparison h > 65504.0f16
folds to 0. For u = 70000 the real value is +Inf. */
__attribute__((noipa)) int
g (unsigned a)
{
unsigned u = a % 100001u; /* u in [0, 100000] */
_Float16 h = (_Float16) u;
return h > 65504.0f16;
}
int
main (void)
{
volatile unsigned v = 70000u;
if (g (v) != 1)
__builtin_abort ();
return 0;
}
aborts on aarch64 at -O2 and passes at -O0