https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110335
Bug ID: 110335 Summary: int converted to double should be considered non-nan and non-nan*non-nan is still non-nan Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` void h (int n, int from, int to) { double dto = to; double damt = n * dto; if (damt != damt) __builtin_trap(); } void h1 (double dto, double n) { if (dto != dto) __builtin_unreachable(); if (n != n) __builtin_unreachable(); double damt = n * dto; if (damt != damt) __builtin_trap(); } ``` I would assume this two functions be optimized to just `return;` LLVM is able to optimize h but not h1.