From: Aaron Sawdey Date: Tue, 12 Dec 2017 22:22:53 +0000 (-0600) Subject: re PR target/82190 (Possibly latent miscompilation issue on ppc64le-linux-gnu for... X-Git-Tag: upstream/12.2.0~34909 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=708eab9b5bfdb5be44253dbac5f58cea5c652c55;p=platform%2Fupstream%2Fgcc.git re PR target/82190 (Possibly latent miscompilation issue on ppc64le-linux-gnu for memcpy-bi.c with -fweb -fno-optimize-strlen) 2017-12-12 Aaron Sawdey PR target/82190 * config/rs6000/rs6000-string.c (expand_block_compare, expand_strn_compare): Fix set_mem_size() calls. From-SVN: r255592 --- diff --git a/gcc/config/rs6000/rs6000-string.c b/gcc/config/rs6000/rs6000-string.c index 8c2a93e..1ff4284 100644 --- a/gcc/config/rs6000/rs6000-string.c +++ b/gcc/config/rs6000/rs6000-string.c @@ -459,14 +459,14 @@ expand_block_compare (rtx operands[]) rtx src1_reg = copy_addr_to_reg (XEXP (src1, 0)); src1 = replace_equiv_address (src1, src1_reg); } - set_mem_size (src1, cmp_bytes); + set_mem_size (src1, load_mode_size); if (!REG_P (XEXP (src2, 0))) { rtx src2_reg = copy_addr_to_reg (XEXP (src2, 0)); src2 = replace_equiv_address (src2, src2_reg); } - set_mem_size (src2, cmp_bytes); + set_mem_size (src2, load_mode_size); do_load_for_compare (tmp_reg_src1, src1, load_mode); do_load_for_compare (tmp_reg_src2, src2, load_mode); @@ -937,14 +937,14 @@ expand_strn_compare (rtx operands[], int no_length) rtx src1_reg = copy_addr_to_reg (XEXP (src1, 0)); src1 = replace_equiv_address (src1, src1_reg); } - set_mem_size (src1, cmp_bytes); + set_mem_size (src1, load_mode_size); if (!REG_P (XEXP (src2, 0))) { rtx src2_reg = copy_addr_to_reg (XEXP (src2, 0)); src2 = replace_equiv_address (src2, src2_reg); } - set_mem_size (src2, cmp_bytes); + set_mem_size (src2, load_mode_size); do_load_for_compare (tmp_reg_src1, src1, load_mode); do_load_for_compare (tmp_reg_src2, src2, load_mode); @@ -1096,14 +1096,14 @@ expand_strn_compare (rtx operands[], int no_length) rtx src1_reg = copy_addr_to_reg (XEXP (src1, 0)); src1 = replace_equiv_address (src1, src1_reg); } - set_mem_size (src1, cmp_bytes); + set_mem_size (src1, load_mode_size); if (!REG_P (XEXP (src2, 0))) { rtx src2_reg = copy_addr_to_reg (XEXP (src2, 0)); src2 = replace_equiv_address (src2, src2_reg); } - set_mem_size (src2, cmp_bytes); + set_mem_size (src2, load_mode_size); /* Construct call to strcmp/strncmp to compare the rest of the string. */ if (no_length) diff --git a/gcc/testsuite/gcc.dg/pr82190.c b/gcc/testsuite/gcc.dg/pr82190.c new file mode 100644 index 0000000..aa8cc85 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr82190.c @@ -0,0 +1,22 @@ +/* PR target/82190 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-optimize-strlen -fweb" } */ + +char src[64] __attribute__ ((aligned)) = "aaaaaaa"; +char dst[64] __attribute__ ((aligned)); + +int +main () +{ + __builtin_memcpy (dst, src, 6); + if (__builtin_memcmp (dst, src, 6)) + __builtin_abort (); + + __builtin_memcpy (dst, src, 7); + if (__builtin_memcmp (dst, src, 7)) + __builtin_abort (); + + return 0; +} + +