aboutsummaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2003-08-26 13:22:14 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2003-08-26 13:22:14 +0000
commitcf42869d28e645cd7bffb3a3a948807dffb93d6b (patch)
treec8a37390f8dba8c2397917760e73ce8179a365a1 /gcc/simplify-rtx.c
parenta103ca2cde431b09326d1378eaaefd45de7bc3af (diff)
downloadgcc-cf42869d28e645cd7bffb3a3a948807dffb93d6b.zip
gcc-cf42869d28e645cd7bffb3a3a948807dffb93d6b.tar.gz
gcc-cf42869d28e645cd7bffb3a3a948807dffb93d6b.tar.bz2
builtins.c (fold_builtin_bitop): New function to perform constant folding of ffs...
* 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. From-SVN: r70806
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 36a8585..919bea6 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: