From e4d2f1db862e08562182369ee989f521070e456e Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 21 Oct 2014 12:38:36 +0000 Subject: [PATCH] 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 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 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/optimize-bswaphi-1.c | 16 +++++++++++++++- gcc/tree-ssa-math-opts.c | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 978d7dc57c7..6b1e1bbc19a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-10-21 Thomas Preud'homme + + * 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 * tree-ssa-phiopt.c (value_replacement): Properly verify we diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 920fd48c404..57735a16164 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-10-21 Thomas Preud'homme + + * gcc.dg/optimize-bswaphi-1.c: New bswap pass test. + 2014-10-21 Richard Biener * g++.dg/ipa/devirt-42.C: Fix dump scanning routines. diff --git a/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c b/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c index 3e51f043cae..18aba284e26 100644 --- a/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c +++ b/gcc/testsuite/gcc.dg/optimize-bswaphi-1.c @@ -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" } } */ diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 3c6e9355fff..2ef2333bc11 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -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) { -- 2.30.2