https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111280
Bug ID: 111280 Summary: CLZ(0) generated when CLZ_DEFINED_VALUE_AT_ZERO is false Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- GCC may generate an internal call to CLZ with 0 when CLZ_DEFINED_VALUE_AT_ZERO is false, which can be seen with gcc.c-torture/execute/920501-6.c where sccp changes a loop to _36 = t_10(D) != 0; _35 = .CLZ (t_10(D)); _34 = 63 - _35; _33 = (unsigned int) _34; _32 = (long long unsigned int) _33; _31 = _32 + 1; b_38 = _36 ? _31 : 1; The value _35 is not used when t_10(D) is 0, so it may be reasonable to allow this. But the value _35 may then be any value, so _34 may overflow. I.e., the calculation _34 = 63 - _35; must be changed to be done unsigned. And the ranges calculated during the dom3 pass claims that _35 has a range _35 : [irange] int [0, 63] which also is wrong.