https://gcc.gnu.org/g:181861b072ff1ef650c1a9d0290a4a672b9e747c
commit r15-1013-g181861b072ff1ef650c1a9d0290a4a672b9e747c Author: Jakub Jelinek <ja...@redhat.com> Date: Tue Jun 4 15:52:09 2024 +0200 fold-const: Handle CTZ like CLZ in tree_call_nonnegative_warnv_p [PR115337] I think we can handle CTZ exactly like CLZ in tree_call_nonnegative_warnv_p. Like CLZ, if it is UB at zero, the result range is [0, prec-1] and if it is well defined at zero, the second argument provides the value at zero. 2024-06-04 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/115337 * fold-const.cc (tree_call_nonnegative_warnv_p): Handle CASE_CFN_CTZ like CASE_CFN_CLZ. Diff: --- gcc/fold-const.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 048c654c848..92b048c307e 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -15250,6 +15250,7 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1, return true; CASE_CFN_CLZ: + CASE_CFN_CTZ: if (arg1) return RECURSE (arg1); return true;