diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-26 13:22:14 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-26 13:22:14 +0000 |
commit | 70fb4c079170fe4c00d0d6b7747c9a2ce822f9d1 (patch) | |
tree | c8a37390f8dba8c2397917760e73ce8179a365a1 /gcc/simplify-rtx.c | |
parent | 2b68965dfbb4401f1fbe255590f286caecf6e5c3 (diff) | |
download | gcc-70fb4c079170fe4c00d0d6b7747c9a2ce822f9d1.tar.gz |
* builtins.c (fold_builtin_bitop): New function to perform constant
folding of ffs, clz, ctz, popcount and parity builtin functions
and their long and long long variants (such as ffsl and ffsll).
(fold_builtin): fold_builtin_bitop when appropriate.
* simplify-rtx.c (simplify_unary_operation): Honor both
CLZ_DEFINED_VALUE_AT_ZERO and CTZ_DEFINED_VALUE_AT_ZERO when
evaluating clz and ctz at compile-time, for operands wider
than HOST_WIDE_INT.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70806 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r-- | gcc/simplify-rtx.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 36a858536c7..919bea6aae2 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -649,24 +649,23 @@ simplify_unary_operation (enum rtx_code code, enum machine_mode mode, case CLZ: hv = 0; - if (h1 == 0) - lv = GET_MODE_BITSIZE (mode) - floor_log2 (l1) - 1; - else + if (h1 != 0) lv = GET_MODE_BITSIZE (mode) - floor_log2 (h1) - 1 - HOST_BITS_PER_WIDE_INT; + else if (l1 != 0) + lv = GET_MODE_BITSIZE (mode) - floor_log2 (l1) - 1; + else if (! CLZ_DEFINED_VALUE_AT_ZERO (mode, lv)) + lv = GET_MODE_BITSIZE (mode); break; case CTZ: hv = 0; - if (l1 == 0) - { - if (h1 == 0) - lv = GET_MODE_BITSIZE (mode); - else - lv = HOST_BITS_PER_WIDE_INT + exact_log2 (h1 & -h1); - } - else + if (l1 != 0) lv = exact_log2 (l1 & -l1); + else if (h1 != 0) + lv = HOST_BITS_PER_WIDE_INT + exact_log2 (h1 & -h1); + else if (! CTZ_DEFINED_VALUE_AT_ZERO (mode, lv)) + lv = GET_MODE_BITSIZE (mode); break; case POPCOUNT: |