diff options
-rw-r--r-- | gcc/fold-const.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 7030294..d81a71c 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see #include "vec-perm-indices.h" #include "asan.h" #include "gimple-range.h" +#include "internal-fn.h" /* Nonzero if we are folding constants inside an initializer or a C++ manifestly-constant-evaluated context; zero otherwise. @@ -14861,7 +14862,6 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1, CASE_CFN_FFS: CASE_CFN_PARITY: CASE_CFN_POPCOUNT: - CASE_CFN_CLZ: CASE_CFN_CLRSB: case CFN_BUILT_IN_BSWAP16: case CFN_BUILT_IN_BSWAP32: @@ -14870,6 +14870,22 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1, /* Always true. */ return true; + CASE_CFN_CLZ: + if (fn != CFN_CLZ) + return true; + else if (INTEGRAL_TYPE_P (TREE_TYPE (arg0))) + { + tree atype = TREE_TYPE (arg0); + int val = 0; + if (direct_internal_fn_supported_p (IFN_CLZ, atype, + OPTIMIZE_FOR_BOTH) + && CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (atype), + val) == 2 + && val >= 0) + return true; + } + break; + CASE_CFN_SQRT: CASE_CFN_SQRT_FN: /* sqrt(-0.0) is -0.0. */ |