https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126475
Bug ID: 126475
Summary: [13/14/15/16/17 Regression] x * { 0.0f, 1.0f, ... }
must not become x & mask when NaNs/Infs are honoured
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: ---
typedef float v4sf __attribute__((vector_size (16)));
__attribute__((noipa))
static v4sf f (v4sf x)
{
return x * (v4sf) { 0.0f, 1.0f, 0.0f, 1.0f };
}
__attribute__((noipa))
static v4sf mk (float a, float b, float c, float d)
{
v4sf r = { a, b, c, d };
return r;
}
int main (void)
{
v4sf x = mk (__builtin_inff (), 1.0f, __builtin_nanf (""), 3.0f);
v4sf r = f (x);
__builtin_printf ("r = %f %f %f %f\n", (double) r[0], (double) r[1],
(double) r[2], (double) r[3]);
__builtin_printf ("isnan(r[0]) = %d isnan(r[2]) = %d\n",
__builtin_isnan (r[0]), __builtin_isnan (r[2]));
if (r[1] != 1.0f || r[3] != 3.0f)
__builtin_abort ();
/* +Inf * 0.0f and NaN * 0.0f are both NaN in IEEE-754. */
if (!__builtin_isnan (r[0]) || !__builtin_isnan (r[2]))
__builtin_abort ();
return 0;
}
aborts at -O2 -fno-signed-zeros on aarch64. GCC 8 seems to work fine, so
marking as regression.