diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-04-28 20:20:37 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-04-28 20:20:37 +0000 |
commit | 1cee90adce76bf3df916a16cbf24460b25578892 (patch) | |
tree | 809e0ddad6cc875da3ddceead9d1ce04c946ef69 /gcc/builtins.c | |
parent | f084c625c4363731ccff2183b6b60bb3f8338558 (diff) |
Use target-independent semantics for wi::clz and wi::ctz.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@209872 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index a7a80ea7435..140d6ba1a5b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8080,6 +8080,7 @@ fold_builtin_bitop (tree fndecl, tree arg) /* Optimize for constant argument. */ if (TREE_CODE (arg) == INTEGER_CST && !TREE_OVERFLOW (arg)) { + tree type = TREE_TYPE (arg); int result; switch (DECL_FUNCTION_CODE (fndecl)) @@ -8089,11 +8090,17 @@ fold_builtin_bitop (tree fndecl, tree arg) break; CASE_INT_FN (BUILT_IN_CLZ): - result = wi::clz (arg); + if (wi::ne_p (arg, 0)) + result = wi::clz (arg); + else if (! CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), result)) + result = TYPE_PRECISION (type); break; CASE_INT_FN (BUILT_IN_CTZ): - result = wi::ctz (arg); + if (wi::ne_p (arg, 0)) + result = wi::ctz (arg); + else if (! CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), result)) + result = TYPE_PRECISION (type); break; CASE_INT_FN (BUILT_IN_CLRSB): |