public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test
@ 2013-11-03 17:45 hjl.tools at gmail dot com
  2013-11-03 18:24 ` [Bug target/58981] " hjl.tools at gmail dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-03 17:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

            Bug ID: 58981
           Summary: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c
                    execution test
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com

On x32, revision 203937 gave

FAIL: gcc.target/i386/memset-1.c execution test

Revision 203931 is OK.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/58981] [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
@ 2013-11-03 18:24 ` hjl.tools at gmail dot com
  2013-11-03 20:49 ` hjl.tools at gmail dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-03 18:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |ubizjak at gmail dot com
   Target Milestone|---                         |4.9.0

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
It is caused by r203937.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/58981] [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
  2013-11-03 18:24 ` [Bug target/58981] " hjl.tools at gmail dot com
@ 2013-11-03 20:49 ` hjl.tools at gmail dot com
  2013-11-04  1:22 ` hubicka at ucw dot cz
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-03 20:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
The bug is in

      *count = expand_simple_binop (GET_MODE (*count), PLUS, *count,
                                    saveddest, *count, 1, OPTAB_DIRECT);

(gdb) call debug_rtx (saveddest)
(reg:SI 101)
(gdb) call debug_rtx (*count)
(reg:DI 100)
(gdb) 

Add SImode address to DImode count to update count leads
to count overflow. Instead, we should use mode of address
here:

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 902e169..b27bfb6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -23139,7 +23139,7 @@
expand_set_or_movmem_prologue_epilogue_by_misaligned_moves (rtx destmem, rtx
src
       if (!issetmem)
   *srcptr = expand_simple_binop (GET_MODE (*srcptr), MINUS, *srcptr,
saveddest,
               *srcptr, 1, OPTAB_DIRECT);
-      *count = expand_simple_binop (GET_MODE (*count), PLUS, *count,
+      *count = expand_simple_binop (GET_MODE (saveddest), PLUS, *count,
                saveddest, *count, 1, OPTAB_DIRECT);
       /* We copied at most size + prolog_size.  */
       if (*min_size > (unsigned HOST_WIDE_INT)(size + prolog_size))


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/58981] [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
  2013-11-03 18:24 ` [Bug target/58981] " hjl.tools at gmail dot com
  2013-11-03 20:49 ` hjl.tools at gmail dot com
@ 2013-11-04  1:22 ` hubicka at ucw dot cz
  2013-11-04  1:50 ` hjl.tools at gmail dot com
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hubicka at ucw dot cz @ 2013-11-04  1:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

--- Comment #3 from Jan Hubicka <hubicka at ucw dot cz> ---
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981
> 
> --- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
> The bug is in
> 
>       *count = expand_simple_binop (GET_MODE (*count), PLUS, *count,
>                                     saveddest, *count, 1, OPTAB_DIRECT);
> 
> (gdb) call debug_rtx (saveddest)
> (reg:SI 101)
> (gdb) call debug_rtx (*count)
> (reg:DI 100)
> (gdb) 
> 
> Add SImode address to DImode count to update count leads
> to count overflow. Instead, we should use mode of address
> here:
> 
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 902e169..b27bfb6 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -23139,7 +23139,7 @@
> expand_set_or_movmem_prologue_epilogue_by_misaligned_moves (rtx destmem, rtx
> src
>        if (!issetmem)
>    *srcptr = expand_simple_binop (GET_MODE (*srcptr), MINUS, *srcptr,
> saveddest,
>                *srcptr, 1, OPTAB_DIRECT);
> -      *count = expand_simple_binop (GET_MODE (*count), PLUS, *count,
> +      *count = expand_simple_binop (GET_MODE (saveddest), PLUS, *count,

This looks OK, Thanks for looking into it!
Honza

>                 saveddest, *count, 1, OPTAB_DIRECT);
>        /* We copied at most size + prolog_size.  */
>        if (*min_size > (unsigned HOST_WIDE_INT)(size + prolog_size))
> 
> -- 
> You are receiving this mail because:
> You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/58981] [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2013-11-04  1:22 ` hubicka at ucw dot cz
@ 2013-11-04  1:50 ` hjl.tools at gmail dot com
  2013-11-04  5:36 ` [Bug middle-end/58981] " hjl.tools at gmail dot com
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-04  1:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
The real bug seems in set_storage_via_setmem in expr.c:

  for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
       mode = GET_MODE_WIDER_MODE (mode))
    {
      enum insn_code code = direct_optab_handler (setmem_optab, mode);

      if (code != CODE_FOR_nothing
          /* We don't need MODE to be narrower than
             BITS_PER_HOST_WIDE_INT here because if SIZE is less than
             ^^^^^^^^^^^^^^^^^^^^^^ Shouldn't it be BITS_PER_WORD?

             the mode mask, as it is returned by the macro, it will
             definitely be less than the actual mode mask.  */
          && ((CONST_INT_P (size)
               && ((unsigned HOST_WIDE_INT) INTVAL (size)
                   <= (GET_MODE_MASK (mode) >> 1)))
              || GET_MODE_BITSIZE (mode) >= BITS_PER_WORD))

When Pmode != word_mode, we are using word_mode for SIZE
to set memory.  Shouldn't it be

GET_MODE_BITSIZE (mode) >= GET_MODE_BITSIZE (Pmode)

instead?  The memory size will be less than the bits of Pmode.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2013-11-04  1:50 ` hjl.tools at gmail dot com
@ 2013-11-04  5:36 ` hjl.tools at gmail dot com
  2013-11-04  6:03 ` hjl.tools at gmail dot com
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-04  5:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-04
          Component|target                      |middle-end
     Ever confirmed|0                           |1

--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
emit_block_move_via_movmem has the same problem.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (4 preceding siblings ...)
  2013-11-04  5:36 ` [Bug middle-end/58981] " hjl.tools at gmail dot com
@ 2013-11-04  6:03 ` hjl.tools at gmail dot com
  2013-11-04 10:35 ` [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size hjl.tools at gmail dot com
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-04  6:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
A testcase for memcpy:

[hjl@gnu-32 gcc]$ cat /tmp/memcpy-2.c 
/* { dg-do run } */
/* { dg-options "-O2 -minline-all-stringops" } */

extern void abort (void);
extern void exit (int);

#define MAX_OFFSET (sizeof (long long))
#define MAX_COPY (8 * sizeof (long long))
#define MAX_EXTRA (sizeof (long long))

#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)

static union {
  char buf[MAX_LENGTH];
  long long align_int;
  long double align_fp;
} u;

char A[MAX_LENGTH];

main ()
{
  int off, len, i;
  char *p, *q;

  for (i = 0; i < MAX_LENGTH; i++)
    A[i] = 'A';

  for (off = 0; off < MAX_OFFSET; off++)
    for (len = 1; len < MAX_COPY; len++)
      {
    for (i = 0; i < MAX_LENGTH; i++)
      u.buf[i] = 'a';

    p = __builtin_memcpy (u.buf + off, A, len);
    if (p != u.buf + off)
      abort ();

    q = u.buf;
    for (i = 0; i < off; i++, q++)
      if (*q != 'a')
        abort ();

    for (i = 0; i < len; i++, q++)
      if (*q != 'A')
        abort ();

    for (i = 0; i < MAX_EXTRA; i++, q++)
      if (*q != 'a')
        abort ();
      }

  exit(0);
}

[hjl@gnu-32 gcc]$ ./xgcc -B./ -O2 -mx32 /tmp/memcpy-2.c -minline-all-stringops
[hjl@gnu-32 gcc]$ ./a.out 
Segmentation fault
[hjl@gnu-32 gcc]$


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (5 preceding siblings ...)
  2013-11-04  6:03 ` hjl.tools at gmail dot com
@ 2013-11-04 10:35 ` hjl.tools at gmail dot com
  2014-04-22 11:37 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hjl.tools at gmail dot com @ 2013-11-04 10:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00179.html


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (6 preceding siblings ...)
  2013-11-04 10:35 ` [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size hjl.tools at gmail dot com
@ 2014-04-22 11:37 ` jakub at gcc dot gnu.org
  2014-07-16 13:30 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-22 11:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.9.0                       |4.9.1

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.0 has been released


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (7 preceding siblings ...)
  2014-04-22 11:37 ` jakub at gcc dot gnu.org
@ 2014-07-16 13:30 ` jakub at gcc dot gnu.org
  2014-10-30 10:41 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-07-16 13:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.9.1                       |4.9.2

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.1 has been released.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (8 preceding siblings ...)
  2014-07-16 13:30 ` jakub at gcc dot gnu.org
@ 2014-10-30 10:41 ` jakub at gcc dot gnu.org
  2015-06-26 19:56 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-30 10:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.9.2                       |4.9.3

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.2 has been released.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (9 preceding siblings ...)
  2014-10-30 10:41 ` jakub at gcc dot gnu.org
@ 2015-06-26 19:56 ` jakub at gcc dot gnu.org
  2015-06-26 20:28 ` jakub at gcc dot gnu.org
  2015-06-26 21:18 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-06-26 19:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.3 has been released.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (10 preceding siblings ...)
  2015-06-26 19:56 ` jakub at gcc dot gnu.org
@ 2015-06-26 20:28 ` jakub at gcc dot gnu.org
  2015-06-26 21:18 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-06-26 20:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.9.3                       |4.9.4


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size
  2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
                   ` (11 preceding siblings ...)
  2015-06-26 20:28 ` jakub at gcc dot gnu.org
@ 2015-06-26 21:18 ` pinskia at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-06-26 21:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58981

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|4.9.4                       |4.9.0

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed so closing as such.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-06-26 21:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-03 17:45 [Bug target/58981] New: [4.9 Regression] FAIL: gcc.target/i386/memset-1.c execution test hjl.tools at gmail dot com
2013-11-03 18:24 ` [Bug target/58981] " hjl.tools at gmail dot com
2013-11-03 20:49 ` hjl.tools at gmail dot com
2013-11-04  1:22 ` hubicka at ucw dot cz
2013-11-04  1:50 ` hjl.tools at gmail dot com
2013-11-04  5:36 ` [Bug middle-end/58981] " hjl.tools at gmail dot com
2013-11-04  6:03 ` hjl.tools at gmail dot com
2013-11-04 10:35 ` [Bug middle-end/58981] movmem/setmem use mode wider than Pmode for size hjl.tools at gmail dot com
2014-04-22 11:37 ` jakub at gcc dot gnu.org
2014-07-16 13:30 ` jakub at gcc dot gnu.org
2014-10-30 10:41 ` jakub at gcc dot gnu.org
2015-06-26 19:56 ` jakub at gcc dot gnu.org
2015-06-26 20:28 ` jakub at gcc dot gnu.org
2015-06-26 21:18 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).