public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass
@ 2012-07-01 13:00 ubizjak at gmail dot com
  2012-07-01 17:16 ` [Bug rtl-optimization/53827] " ubizjak at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2012-07-01 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53827
           Summary: [alpha]: Invalid insn scheduling in sched1 pass
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ubizjak@gmail.com


Following testcase exposes a bug in sched1 pass:

--cut here--
#ifndef MAX_OFFSET
#define MAX_OFFSET (sizeof (long long))
#endif

#ifndef MAX_COPY
#define MAX_COPY 15
#endif

#ifndef MAX_EXTRA
#define MAX_EXTRA (sizeof (long long))
#endif

#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)

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

void reset (void);
void check (int off, int len, int ch);

int test ()
{
  int off;
  char *p;

  reset ();

  p = memset (u.buf + 1, '\0', 15);
  check (1, 15, '\0');

  return 0;
}
--cut here--

This bug can be triggered with a crosscompiler from x86_64-pc-linux-gnu to
alpha-linux-gnu target.

~/gcc-build-alpha/gcc/cc1 -O2 -mcpu=ev6

test:
        .frame $30,16,$26,0
        .mask 0x4000000,-16
        ldgp $29,0($27)  # 39   *prologue_ldgp_1        [length = 4]
$test..ng:
        lda $30,-16($30)         # 41   *adddi_internal/2       [length = 4]
        stq $26,0($30)   # 42   *movdi/9        [length = 4]
        .prologue 1
        jsr $26,reset    # 5    *call_osf_1/3   [length = 16]
        ldgp $29,0($26)
        lda $1,u         # 6    *movdi/7        [length = 4]
        lda $16,1($31)   # 22   *movdi/2        [length = 4]
        lda $17,15($31)  # 23   *movdi/2        [length = 4]
        mov $31,$18      # 24   *movdi/1        [length = 4]
        ldq_u $3,8($1)   # 7    *movdi/8        [length = 4]
        ldq_u $2,1($1)   # 8    *movdi/8        [length = 4]
        lda $4,1($1)     # 9    *adddi_internal/2       [length = 4]
>>>     stb $31,15($1)   # 20   *movqi/4        [length = 4]
        mskqh $3,$4,$3   # 10   mskxh   [length = 4]
        mskql $2,$4,$2   # 11   mskxl   [length = 4]
>>>     stq_u $3,8($1)   # 12   *movdi/9        [length = 4]
        stq_u $2,1($1)   # 13   *movdi/9        [length = 4]
        stb $31,9($1)    # 14   *movqi/4        [length = 4]
        stb $31,10($1)   # 15   *movqi/4        [length = 4]
        stb $31,11($1)   # 16   *movqi/4        [length = 4]
        stb $31,12($1)   # 17   *movqi/4        [length = 4]
        stb $31,13($1)   # 18   *movqi/4        [length = 4]
        stb $31,14($1)   # 19   *movqi/4        [length = 4]
        jsr $26,check    # 25   *call_osf_1/3   [length = 16]
        ldgp $29,0($26)
        ldq $26,0($30)   # 45   *movdi/8        [length = 4]
        mov $31,$0       # 30   *movdi/1        [length = 4]
        lda $30,16($30)  # 47   *adddi_internal/2       [length = 4]
        ret $31,($26),1  # 48   *return_internal        [length = 4]
        .end test

(insn 20) has been moved above (insn 12) in sched1 pass, although (insn 12)
stores DImode value to $1+8.

For reference, (insn 12) is defined as:

(insn 12 11 13 2 (set (mem/c:DI (and:DI (plus:DI (reg/f:DI 71)
                    (const_int 8 [0x8]))
                (const_int -8 [0xfffffffffffffff8])) [0 S8 A64])
        (reg:DI 73)) t.c:31 225 {*movdi}
     (expr_list:REG_DEAD (reg:DI 73)
        (nil)))

and (insn 20):

(insn 20 9 10 2 (set (mem/c:QI (plus:DI (reg/f:DI 71)
                (const_int 15 [0xf])) [0 MEM[(void *)&u + 1B]+14 S1 A8])
        (const_int 0 [0])) t.c:31 228 {*movqi}
     (expr_list:REG_DEAD (reg/f:DI 71)
        (nil)))

This is the only failure in gcc.c-torture/execute/memset-2.c execution failure
(and probably also in gcc.c-torture/execute/builtins/memset-chk.c execution
failure) [1]. It looks like off-by-one somewhere in the sched1 pass to me,
please note that other insns with offsets less than 15 are not moved.

[1] http://gcc.gnu.org/ml/gcc-testresults/2012-07/msg00017.html


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

* [Bug rtl-optimization/53827] [alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
@ 2012-07-01 17:16 ` ubizjak at gmail dot com
  2012-07-02  9:02 ` [Bug rtl-optimization/53827] [4.8 Regression][alpha]: " rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2012-07-01 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-07-01
                 CC|                            |aoliva at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Uros Bizjak <ubizjak at gmail dot com> 2012-07-01 17:16:21 UTC ---
The problem is in memrefs_conflict_p in alias.c:

Calling this function with:

xsize = 8

x:
(and:DI (plus:DI (reg/f:DI 71)
        (const_int 8 [0x8]))
    (const_int -8 [0xfffffffffffffff8]))

ysize = 1

y:
(plus:DI (reg/f:DI 71)
    (const_int 15 [0xf]))

c = 0

returns 0, implying that these references don't conflict. Fail.

Suspected commit:

2012-06-21  Alexandre Oliva  <aoliva@redhat.com>

    PR debug/53671
    PR debug/49888
    * alias.c (memrefs_conflict_p): Improve handling of AND for alignment.


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
  2012-07-01 17:16 ` [Bug rtl-optimization/53827] " ubizjak at gmail dot com
@ 2012-07-02  9:02 ` rguenth at gcc dot gnu.org
  2012-07-02 12:07 ` aoliva at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-02  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Target Milestone|---                         |4.8.0
            Summary|[alpha]: Invalid insn       |[4.8 Regression][alpha]:
                   |scheduling in sched1 pass   |Invalid insn scheduling in
                   |                            |sched1 pass


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
  2012-07-01 17:16 ` [Bug rtl-optimization/53827] " ubizjak at gmail dot com
  2012-07-02  9:02 ` [Bug rtl-optimization/53827] [4.8 Regression][alpha]: " rguenth at gcc dot gnu.org
@ 2012-07-02 12:07 ` aoliva at gcc dot gnu.org
  2012-07-03  7:05 ` ubizjak at gmail dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: aoliva at gcc dot gnu.org @ 2012-07-02 12:07 UTC (permalink / raw)
  To: gcc-bugs

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

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |aoliva at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #2 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2012-07-02 12:07:09 UTC ---
My thinko.  This patchlet ought to fix it.  Testing now...

Index: gcc/alias.c
===================================================================
--- gcc/alias.c.orig    2012-07-02 09:04:06.193137799 -0300
+++ gcc/alias.c    2012-07-02 09:04:08.000000000 -0300
@@ -2107,7 +2107,7 @@ memrefs_conflict_p (int xsize, rtx x, in
       if (xsize > 0 && sc < 0 && -uc == (uc & -uc))
     {
       xsize -= sc + 1;
-      c -= sc;
+      c -= sc + 1;
       return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)),
                      ysize, y, c);
     }
@@ -2119,7 +2119,7 @@ memrefs_conflict_p (int xsize, rtx x, in
       if (ysize > 0 && sc < 0 && -uc == (uc & -uc))
     {
       ysize -= sc + 1;
-      c += sc;
+      c += sc + 1;
       return memrefs_conflict_p (xsize, x,
                      ysize, canon_rtx (XEXP (y, 0)), c);
     }


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
                   ` (2 preceding siblings ...)
  2012-07-02 12:07 ` aoliva at gcc dot gnu.org
@ 2012-07-03  7:05 ` ubizjak at gmail dot com
  2012-07-06  7:56 ` ubizjak at gmail dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2012-07-03  7:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Uros Bizjak <ubizjak at gmail dot com> 2012-07-03 07:05:29 UTC ---
(In reply to comment #2)
> My thinko.  This patchlet ought to fix it.  Testing now...

I can confirm that the patch fixes all memset* runtime failures in [1].

[1] http://gcc.gnu.org/ml/gcc-testresults/2012-07/msg00017.html


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
                   ` (3 preceding siblings ...)
  2012-07-03  7:05 ` ubizjak at gmail dot com
@ 2012-07-06  7:56 ` ubizjak at gmail dot com
  2012-07-06 11:37 ` aoliva at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2012-07-06  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Uros Bizjak <ubizjak at gmail dot com> 2012-07-06 07:55:59 UTC ---
Alexandre, can you please commit the patch from Comment 2? I have bootstrapped
and regression tested it on alphaev68-pc-linux-gnu (an AND target) without
problems.


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
                   ` (4 preceding siblings ...)
  2012-07-06  7:56 ` ubizjak at gmail dot com
@ 2012-07-06 11:37 ` aoliva at gcc dot gnu.org
  2012-07-06 12:19 ` aoliva at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: aoliva at gcc dot gnu.org @ 2012-07-06 11:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2012-07-06 11:37:17 UTC ---
Author: aoliva
Date: Fri Jul  6 11:37:14 2012
New Revision: 189325

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189325
Log:
PR rtl-optimization/53827
PR debug/53671
PR debug/49888
* alias.c (memrefs_conflict_p): Adjust offset and size by the
same amount for alignment ANDs.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/alias.c


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
                   ` (5 preceding siblings ...)
  2012-07-06 11:37 ` aoliva at gcc dot gnu.org
@ 2012-07-06 12:19 ` aoliva at gcc dot gnu.org
  2013-01-16  4:32 ` aoliva at gcc dot gnu.org
  2013-01-18 11:01 ` aoliva at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: aoliva at gcc dot gnu.org @ 2012-07-06 12:19 UTC (permalink / raw)
  To: gcc-bugs

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

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2012-07-06 11:37:17 UTC ---
Author: aoliva
Date: Fri Jul  6 11:37:14 2012
New Revision: 189325

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189325
Log:
PR rtl-optimization/53827
PR debug/53671
PR debug/49888
* alias.c (memrefs_conflict_p): Adjust offset and size by the
same amount for alignment ANDs.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/alias.c

--- Comment #6 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2012-07-06 12:18:51 UTC ---
Fixed


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
                   ` (6 preceding siblings ...)
  2012-07-06 12:19 ` aoliva at gcc dot gnu.org
@ 2013-01-16  4:32 ` aoliva at gcc dot gnu.org
  2013-01-18 11:01 ` aoliva at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: aoliva at gcc dot gnu.org @ 2013-01-16  4:32 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2013-01-16 04:31:39 UTC ---
Author: aoliva
Date: Wed Jan 16 04:31:30 2013
New Revision: 195227

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195227
Log:
PR rtl-optimization/55547
PR rtl-optimization/53827
PR debug/53671
PR debug/49888
* alias.c (memrefs_conflict_p): Set sizes to negative after
AND adjustments.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/alias.c


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

* [Bug rtl-optimization/53827] [4.8 Regression][alpha]: Invalid insn scheduling in sched1 pass
  2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
                   ` (7 preceding siblings ...)
  2013-01-16  4:32 ` aoliva at gcc dot gnu.org
@ 2013-01-18 11:01 ` aoliva at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: aoliva at gcc dot gnu.org @ 2013-01-18 11:01 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #8 from Alexandre Oliva <aoliva at gcc dot gnu.org> 2013-01-18 10:57:51 UTC ---
Author: aoliva
Date: Fri Jan 18 10:57:36 2013
New Revision: 195289

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195289
Log:
PR rtl-optimization/55547
PR rtl-optimization/53827
PR debug/53671
PR debug/49888
* alias.c (offset_overlap_p): New, factored out of...
(memrefs_conflict_p): ... this.  Use absolute sizes.  Retain
the conservative special case for symbolic constants.  Don't
adjust zero sizes on alignment.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/alias.c


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

end of thread, other threads:[~2013-01-18 10:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-01 13:00 [Bug rtl-optimization/53827] New: [alpha]: Invalid insn scheduling in sched1 pass ubizjak at gmail dot com
2012-07-01 17:16 ` [Bug rtl-optimization/53827] " ubizjak at gmail dot com
2012-07-02  9:02 ` [Bug rtl-optimization/53827] [4.8 Regression][alpha]: " rguenth at gcc dot gnu.org
2012-07-02 12:07 ` aoliva at gcc dot gnu.org
2012-07-03  7:05 ` ubizjak at gmail dot com
2012-07-06  7:56 ` ubizjak at gmail dot com
2012-07-06 11:37 ` aoliva at gcc dot gnu.org
2012-07-06 12:19 ` aoliva at gcc dot gnu.org
2013-01-16  4:32 ` aoliva at gcc dot gnu.org
2013-01-18 11:01 ` aoliva 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).