Commit fef015a8 by Andreas Krebbel Committed by Andreas Krebbel

tree-ssa-math-opts.c (find_bswap): Increase the search depth in order to match…

tree-ssa-math-opts.c (find_bswap): Increase the search depth in order to match bswaps with signed source operands.

2009-06-23  Andreas Krebbel  <krebbel1@de.ibm.com>

	* tree-ssa-math-opts.c (find_bswap): Increase the search depth in
	order to match bswaps with signed source operands.

2009-06-23  Andreas Krebbel  <krebbel1@de.ibm.com>

	* gcc.dg/optimize-bswapsi-1.c: Add new bswap implementation.
	* gcc.dg/optimize-bswapdi-1.c: Likewise.

From-SVN: r148848
parent 792569a9
2009-06-23 Andreas Krebbel <krebbel1@de.ibm.com>
* tree-ssa-math-opts.c (find_bswap): Increase the search depth in
order to match bswaps with signed source operands.
2009-06-23 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* sdbout.c (sdbout_one_type): Fix braces in switch.
......
2009-06-23 Andreas Krebbel <krebbel1@de.ibm.com>
* gcc.dg/optimize-bswapsi-1.c: Add new bswap implementation.
* gcc.dg/optimize-bswapdi-1.c: Likewise.
2009-06-22 Adam Nemet <anemet@caviumnetworks.com>
* gcc.target/mips/truncate-3.c: New test.
......
......@@ -24,5 +24,25 @@ swap64 (uint64_t in)
return __const_swab64 (in);
}
/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 1 "bswap" } } */
/* This variant is currently used by libgcc. The difference is that
the bswap source and destination have a signed integer type which
requires a slightly higher search depth in order to dive through
the cast as well. */
typedef int DItype __attribute__ ((mode (DI)));
DItype
swap64_b (DItype u)
{
return ((((u) & 0xff00000000000000ull) >> 56)
| (((u) & 0x00ff000000000000ull) >> 40)
| (((u) & 0x0000ff0000000000ull) >> 24)
| (((u) & 0x000000ff00000000ull) >> 8)
| (((u) & 0x00000000ff000000ull) << 8)
| (((u) & 0x0000000000ff0000ull) << 24)
| (((u) & 0x000000000000ff00ull) << 40)
| (((u) & 0x00000000000000ffull) << 56));
}
/* { dg-final { scan-tree-dump-times "64 bit bswap implementation found at" 2 "bswap" } } */
/* { dg-final { cleanup-tree-dump "bswap" } } */
......@@ -31,5 +31,21 @@ swap32_b (uint32_t in)
return a;
}
/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 2 "bswap" } } */
/* This variant is currently used by libgcc. The difference is that
the bswap source and destination have a signed integer type which
requires a slightly higher search depth in order to dive through
the cast as well. */
typedef int SItype __attribute__ ((mode (SI)));
SItype
swap32_c (SItype u)
{
return ((((u) & 0xff000000) >> 24)
| (((u) & 0x00ff0000) >> 8)
| (((u) & 0x0000ff00) << 8)
| (((u) & 0x000000ff) << 24));
}
/* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 3 "bswap" } } */
/* { dg-final { cleanup-tree-dump "bswap" } } */
......@@ -1125,9 +1125,14 @@ find_bswap (gimple stmt)
struct symbolic_number n;
tree source_expr;
/* 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))));
TYPE_SIZE_UNIT (gimple_expr_type (stmt))) + 1);
if (!source_expr)
return NULL_TREE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment