aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-07-19 19:30:05 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-07-19 19:30:05 +0200
commit4fda19ef2b56cd04d557e44e742984e8318b5c3c (patch)
treebab7fdb2faf8ab1a7fe16d23af96298fde377e0b
parent13da0507f3edc3732100780d2c54a2402b7ea124 (diff)
downloadgcc-4fda19ef2b56cd04d557e44e742984e8318b5c3c.zip
gcc-4fda19ef2b56cd04d557e44e742984e8318b5c3c.tar.gz
gcc-4fda19ef2b56cd04d557e44e742984e8318b5c3c.tar.bz2
re PR middle-end/71874 (memmove works wrong)
PR middle-end/71874 * gimple-fold.c (fold_builtin_memory_op): Use get_addr_base_and_unit_offset instead of get_ref_base_and_extent. * g++.dg/torture/pr71874.C: New test. From-SVN: r238484
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimple-fold.c17
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/torture/pr71874.C12
4 files changed, 29 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6665779..a59b4b3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-07-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/71874
+ * gimple-fold.c (fold_builtin_memory_op): Use
+ get_addr_base_and_unit_offset instead of get_ref_base_and_extent.
+
2016-07-19 Uros Bizjak <ubizjak@gmail.com>
* builtins.c: Use HOST_WIDE_INT_1 instead of (HOST_WIDE_INT) 1,
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 3a50088..73c2314 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -796,22 +796,21 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
{
tree src_base, dest_base, fn;
HOST_WIDE_INT src_offset = 0, dest_offset = 0;
- HOST_WIDE_INT size = -1;
- HOST_WIDE_INT maxsize = -1;
- bool reverse;
+ HOST_WIDE_INT maxsize;
srcvar = TREE_OPERAND (src, 0);
- src_base = get_ref_base_and_extent (srcvar, &src_offset,
- &size, &maxsize, &reverse);
+ src_base = get_addr_base_and_unit_offset (srcvar, &src_offset);
+ if (src_base == NULL)
+ src_base = srcvar;
destvar = TREE_OPERAND (dest, 0);
- dest_base = get_ref_base_and_extent (destvar, &dest_offset,
- &size, &maxsize, &reverse);
+ dest_base = get_addr_base_and_unit_offset (destvar,
+ &dest_offset);
+ if (dest_base == NULL)
+ dest_base = destvar;
if (tree_fits_uhwi_p (len))
maxsize = tree_to_uhwi (len);
else
maxsize = -1;
- src_offset /= BITS_PER_UNIT;
- dest_offset /= BITS_PER_UNIT;
if (SSA_VAR_P (src_base)
&& SSA_VAR_P (dest_base))
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 00f0274..17fcb00 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2016-07-19 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/71874
+ * g++.dg/torture/pr71874.C: New test.
+
PR middle-end/71734
* g++.dg/vect/pr70729.cc: Don't include string.h or xmmintrin.h.
(my_alloc): Rewritten to use __builtin_posix_memalign and
diff --git a/gcc/testsuite/g++.dg/torture/pr71874.C b/gcc/testsuite/g++.dg/torture/pr71874.C
new file mode 100644
index 0000000..d9b4e2f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr71874.C
@@ -0,0 +1,12 @@
+// PR middle-end/71874
+// { dg-do run }
+
+int
+main ()
+{
+ char str[] = "abcdefghijklmnopqrstuvwxyzABCDEF";
+ __builtin_memmove (str + 20, str + 15, 11);
+ if (__builtin_strcmp (str, "abcdefghijklmnopqrstpqrstuvwxyzF") != 0)
+ __builtin_abort ();
+ return 0;
+}