diff options
| author | Richard Biener <rguenther@suse.de> | 2014-07-25 07:44:57 +0000 |
|---|---|---|
| committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-07-25 07:44:57 +0000 |
| commit | b2505143369334866ed98d69f08033068b24de34 (patch) | |
| tree | c7fe34fd006f2ff66fbe4a743da4b4b825b9c156 /gcc/testsuite/gcc.dg/fold-cstring.c | |
| parent | 1ed85d52ef443e528bfccc64d81a7b263e9defa3 (diff) | |
| download | gcc-b2505143369334866ed98d69f08033068b24de34.zip gcc-b2505143369334866ed98d69f08033068b24de34.tar.gz gcc-b2505143369334866ed98d69f08033068b24de34.tar.bz2 | |
re PR middle-end/61762 (failure to optimize memcpy from constant string)
2014-07-25 Richard Biener <rguenther@suse.de>
PR middle-end/61762
PR middle-end/61894
* fold-const.c (native_encode_int): Add and handle offset
parameter to do partial encodings of expr.
(native_encode_fixed): Likewise.
(native_encode_real): Likewise.
(native_encode_complex): Likewise.
(native_encode_vector): Likewise.
(native_encode_string): Likewise.
(native_encode_expr): Likewise.
* fold-const.c (native_encode_expr): Add offset parameter
defaulting to -1.
* gimple-fold.c (fold_string_cst_ctor_reference): Remove.
(fold_ctor_reference): Handle all reads from tcc_constant
ctors.
* gcc.dg/pr61762.c: New testcase.
* gcc.dg/fold-cstring.c: Likewise.
* gcc.dg/fold-cvect.c: Likewise.
From-SVN: r213045
Diffstat (limited to 'gcc/testsuite/gcc.dg/fold-cstring.c')
| -rw-r--r-- | gcc/testsuite/gcc.dg/fold-cstring.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fold-cstring.c b/gcc/testsuite/gcc.dg/fold-cstring.c new file mode 100644 index 0000000..f92b120 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-cstring.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +/* The following are testcases for native_interpret_int, + native_interpret_complex and native_interpret_vector decoding + pieces of a string constant encoded by native_encode_string. */ + +extern void abort (void); + +/* We should fold all reads from xconstant and eliminate it, removing + the reference to blah which cannot be resolved at link time. */ +extern int blah; + +static const struct { + int *y; + const char x[32] __attribute__((aligned(32))); +} xconstant = { &blah, "01234567899876543210123456789000" }; + +typedef int v4si __attribute__((vector_size(16))); + +int main() +{ + if (sizeof (int) != 4) + return 0; + if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) + { + if (*(int *)&xconstant.x[4] != 0x34353637) + abort (); + if ((*(v4si *)&xconstant.x[16])[1] != 0x31323334) + abort (); + if (__imag (*(_Complex int *)&xconstant.x[8]) != 0x37363534) + abort (); + } + else if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + { + if (*(int *)&xconstant.x[4] != 0x37363534) + abort (); + if ((*(v4si *)&xconstant.x[16])[1] != 0x34333231) + abort (); + if (__imag (*(_Complex int *)&xconstant.x[8]) != 0x34353637) + abort (); + } + return 0; +} |
