Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.

--- gcc/fold-const.cc.jj        2024-06-04 12:08:14.671262211 +0200
+++ gcc/fold-const.cc   2024-06-04 10:56:57.575425348 +0200
@@ -15250,6 +15250,7 @@ tree_call_nonnegative_warnv_p (tree type
       return true;
 
     CASE_CFN_CLZ:
+    CASE_CFN_CTZ:
       if (arg1)
        return RECURSE (arg1);
       return true;

        Jakub

Reply via email to