tree-ssa-math-opts.c (find_bswap_or_nop_1): Fix creation of MARKER_BYTE_UNKNOWN markers when handling casts.

2014-10-21  Thomas Preud'homme  <thomas.preudhomme@arm.com>

    gcc/
    * tree-ssa-math-opts.c (find_bswap_or_nop_1): Fix creation of
    MARKER_BYTE_UNKNOWN markers when handling casts.

    gcc/testsuite/
    * gcc.dg/optimize-bswaphi-1.c: New bswap pass test.

From-SVN: r216511
This commit is contained in:
Thomas Preud'homme 2014-10-21 12:38:36 +00:00 committed by Thomas Preud'homme
parent 1a6230a84d
commit e4d2f1db86
4 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2014-10-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
* tree-ssa-math-opts.c (find_bswap_or_nop_1): Fix creation of
MARKER_BYTE_UNKNOWN markers when handling casts.
2014-10-21 Richard Biener <rguenther@suse.de>
* tree-ssa-phiopt.c (value_replacement): Properly verify we

View File

@ -1,3 +1,7 @@
2014-10-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
* gcc.dg/optimize-bswaphi-1.c: New bswap pass test.
2014-10-21 Richard Biener <rguenther@suse.de>
* g++.dg/ipa/devirt-42.C: Fix dump scanning routines.

View File

@ -42,6 +42,20 @@ uint32_t read_be16_3 (unsigned char *data)
return *(data + 1) | (*data << 8);
}
typedef int SItype __attribute__ ((mode (SI)));
typedef int HItype __attribute__ ((mode (HI)));
/* Test that detection of significant sign extension works correctly. This
checks that unknown byte marker are set correctly in cast of cast. */
HItype
swap16 (HItype in)
{
return (HItype) (((in >> 0) & 0xFF) << 8)
| (((in >> 8) & 0xFF) << 0);
}
/* { dg-final { scan-tree-dump-times "16 bit load in target endianness found at" 3 "bswap" } } */
/* { dg-final { scan-tree-dump-times "16 bit bswap implementation found at" 3 "bswap" { xfail alpha*-*-* arm*-*-* } } } */
/* { dg-final { scan-tree-dump-times "16 bit bswap implementation found at" 1 "bswap" { target alpha*-*-* arm*-*-* } } } */
/* { dg-final { scan-tree-dump-times "16 bit bswap implementation found at" 4 "bswap" { xfail alpha*-*-* arm*-*-* } } } */
/* { dg-final { cleanup-tree-dump "bswap" } } */

View File

@ -1916,7 +1916,8 @@ find_bswap_or_nop_1 (gimple stmt, struct symbolic_number *n, int limit)
if (!TYPE_UNSIGNED (n->type) && type_size > old_type_size
&& HEAD_MARKER (n->n, old_type_size))
for (i = 0; i < type_size - old_type_size; i++)
n->n |= MARKER_BYTE_UNKNOWN << (type_size - 1 - i);
n->n |= MARKER_BYTE_UNKNOWN
<< ((type_size - 1 - i) * BITS_PER_MARKER);
if (type_size < 64 / BITS_PER_MARKER)
{