diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2015-07-25 11:19:24 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2015-07-25 11:19:24 +0200 |
commit | 4c141304a869524c909a6a9346b004cda47659fc (patch) | |
tree | 6f03efcb67d70123b98f1040ce38858349386bec /gcc | |
parent | f50d98b54382e7a79e25ec15828f41fa35ad77d0 (diff) | |
download | gcc-4c141304a869524c909a6a9346b004cda47659fc.zip gcc-4c141304a869524c909a6a9346b004cda47659fc.tar.gz gcc-4c141304a869524c909a6a9346b004cda47659fc.tar.bz2 |
re PR target/66648 (incorrect memcpy expansion with unrolled_loop strategy at -O2)
PR target/66648
* config/i386/i386.c (ix86_expand_set_or_movmem): Emit main loop
execution guard when min_size is less than size_needed.
testsuite/ChangeLog:
PR target/66648
* gcc.target/i386/pr66648.c: New test.
From-SVN: r226212
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/pr66648.c | 33 |
4 files changed, 47 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e70f931..60c4ade 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-07-25 Uros Bizjak <ubizjak@gmail.com> + + PR target/66648 + * config/i386/i386.c (ix86_expand_set_or_movmem): Emit main loop + execution guard when min_size is less than size_needed. + 2015-07-25 Sebastian Pop <s.pop@samsung.com> * doc/install.texi: Document supported versions of ISL. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 068cadf..21512c6 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -25113,7 +25113,8 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx count_exp, rtx val_exp, dst = change_address (dst, BLKmode, destreg); set_mem_align (dst, desired_align * BITS_PER_UNIT); epilogue_size_needed = 0; - if (need_zero_guard && !min_size) + if (need_zero_guard + && min_size < (unsigned HOST_WIDE_INT) size_needed) { /* It is possible that we copied enough so the main loop will not execute. */ @@ -25245,7 +25246,7 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx count_exp, rtx val_exp, max_size -= align_bytes; } if (need_zero_guard - && !min_size + && min_size < (unsigned HOST_WIDE_INT) size_needed && (count < (unsigned HOST_WIDE_INT) size_needed || (align_bytes == 0 && count < ((unsigned HOST_WIDE_INT) size_needed diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f832fb1..55e4cb0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-25 Uros Bizjak <ubizjak@gmail.com> + + PR target/66648 + * gcc.target/i386/pr66648.c: New test. + 2015-07-25 Tom de Vries <tom@codesourcery.com> * gcc.dg/graphite/graphite.exp: Include uns-*.c files in diff --git a/gcc/testsuite/gcc.target/pr66648.c b/gcc/testsuite/gcc.target/pr66648.c new file mode 100644 index 0000000..88c126f --- /dev/null +++ b/gcc/testsuite/gcc.target/pr66648.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mstringop-strategy=unrolled_loop -mtune=nocona" } */ + +#define PATTERN 0xdeadbeef +#define SIZE 32 + +struct S { int i; char str[SIZE]; int j; }; + +void __attribute__((noclone, noinline)) +my_memcpy (char *, const char *, unsigned int); + +void +my_memcpy (char *dst, const char *src, unsigned int len) +{ + if (len < 8) + __builtin_abort (); + + __builtin_memcpy (dst, src, len); +} + +int +main (void) +{ + const char str[SIZE]= "1234567890123456789012345678901"; + struct S *s = __builtin_malloc (sizeof (struct S)); + + s->j = PATTERN; + my_memcpy (s->str, str, SIZE); + if (s->j != PATTERN) + __builtin_abort (); + + return 0; +} |