diff options
author | Kai Tietz <ktietz@redhat.com> | 2011-06-27 15:44:52 +0200 |
---|---|---|
committer | Kai Tietz <ktietz@gcc.gnu.org> | 2011-06-27 15:44:52 +0200 |
commit | 5da49a9d153a00776bba423734630b8d361dc53f (patch) | |
tree | 365685b86a946b087f030f0470c455cfb6f3f5ba /gcc/tree-ssa-math-opts.c | |
parent | 9242213f86f6e3e4703b4fb84065608fb5a03985 (diff) | |
download | gcc-5da49a9d153a00776bba423734630b8d361dc53f.zip gcc-5da49a9d153a00776bba423734630b8d361dc53f.tar.gz gcc-5da49a9d153a00776bba423734630b8d361dc53f.tar.bz2 |
tree-ssa-math-opts.c (do_shift_rotate): Zero bits out of type precision after operation.
2011-06-27 Kai Tietz <ktietz@redhat.com>
* tree-ssa-math-opts.c (do_shift_rotate): Zero bits
out of type precision after operation.
(find_bswap): Take for limit value the integer auto-
promotion into account.
ChangeLog
2011-06-27 Kai Tietz <ktietz@redhat.com>
* gcc.dg/optimize-bswapdi-2.c: New test.
From-SVN: r175528
Diffstat (limited to 'gcc/tree-ssa-math-opts.c')
-rw-r--r-- | gcc/tree-ssa-math-opts.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index bc7919a..4da4018 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1543,6 +1543,9 @@ do_shift_rotate (enum tree_code code, default: return false; } + /* Zero unused bits for size. */ + if (n->size < (int)sizeof (HOST_WIDEST_INT)) + n->n &= ((unsigned HOST_WIDEST_INT)1 << (n->size * BITS_PER_UNIT)) - 1; return true; } @@ -1740,15 +1743,16 @@ find_bswap (gimple stmt) struct symbolic_number n; tree source_expr; + int limit; /* The last parameter determines the depth search limit. It usually correlates directly to the number of bytes to be touched. We - increase that number by one here in order to also cover signed -> - unsigned conversions of the src operand as can be seen in - libgcc. */ - source_expr = find_bswap_1 (stmt, &n, - TREE_INT_CST_LOW ( - TYPE_SIZE_UNIT (gimple_expr_type (stmt))) + 1); + increase that number by three here in order to also + cover signed -> unsigned converions of the src operand as can be seen + in libgcc, and for initial shift/and operation of the src operand. */ + limit = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (gimple_expr_type (stmt))); + limit += 1 + (int) ceil_log2 ((unsigned HOST_WIDE_INT) limit); + source_expr = find_bswap_1 (stmt, &n, limit); if (!source_expr) return NULL_TREE; |