public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/34637]  New: ICE in rws_insn_set, at config/ia64/ia64.c:5335
@ 2008-01-02  9:58 rguenth at gcc dot gnu dot org
  2008-01-02 10:11 ` [Bug target/34637] " rguenth at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-02  9:58 UTC (permalink / raw)
  To: gcc-bugs

The following testcase ICEs on the 4.1 branch with -O2 and up and on mainline
with
-O and up.

class Atomic {
public:
  static int add (int add_value, volatile int* dest);
};

inline int Atomic::add (int add_value, volatile int* dest) {
  int sum = 0;
  if (add_value == 1) {
    __asm__ volatile ("mf;;fetchadd4.acq %0=[%1],1;;" : "=r" (sum) : "r" (dest)
: "memory");
    ++sum;
  } else if (add_value == -1) {
    __asm__ volatile ("mf;;fetchadd4.acq %0=[%1],-1;;" : "=r" (sum) : "r"
(dest) : "memory");
    --sum;
  } else {
    int compare_value = 0;
    int exchange_value = 0;
    __asm__ volatile
      (
       "   mf;;"
       "0: ld4 %0=[%7];;"
       "   add %1=%6,%0;;"
       "   zxt4 %0=%0;;"
       "   mov ar.ccv=%0;;"
       "   cmpxchg4.acq %1=[%7],%1,ar.ccv;;"
       "   cmp4.ne p15,p0=%0,%1;"
       "   add %2=%6,%0;"
       "   (p15) br.cond.spnt 0b;;"
       : "=r" (compare_value) ,
       "=r" (exchange_value) ,
       "=r" (sum)
       : "0" (compare_value) ,
       "1" (exchange_value) ,
       "2" (sum) ,
       "r" (add_value) ,
       "r" (dest)
       : "p15", "memory");
  }
  return sum;
};

class FooClass {
private:
  static volatile int _pending_yields;
  static volatile int _pending_decrements;
public:
  void doit();
static void ack() {
    int decrement = _pending_decrements;
    if (decrement > 0) {
      Atomic::add(-decrement, &_pending_decrements);
      Atomic::add(-decrement, &_pending_yields);
    }
  }
};

void FooClass::doit() {
  FooClass::ack();
}

backtrace on mainline with a cross from x86_64 is

#1  0x0000000000d70bea in rws_insn_set (regno=14)
    at /space/rguenther/src/svn/trunk/gcc/config/ia64/ia64.c:5335
#2  0x0000000000d70854 in rws_access_regno (regno=14, flags=
      {is_write = 1, is_fp = 0, is_branch = 0, is_and = 0, is_or = 0,
is_sibcall = 0}, pred=0) at
/space/rguenther/src/svn/trunk/gcc/config/ia64/ia64.c:5431
#3  0x0000000000d70dcf in rws_access_reg (reg=0x2b03312f7b20, flags=
      {is_write = 1, is_fp = 0, is_branch = 0, is_and = 0, is_or = 0,
is_sibcall = 0}, pred=0) at
/space/rguenther/src/svn/trunk/gcc/config/ia64/ia64.c:5541
#4  0x0000000000d715e1 in rtx_needs_barrier (x=0x2b03312f7b20, flags=
      {is_write = 1, is_fp = 0, is_branch = 0, is_and = 0, is_or = 0,
is_sibcall = 0}, pred=0) at
/space/rguenther/src/svn/trunk/gcc/config/ia64/ia64.c:5794
#5  0x0000000000d71534 in rtx_needs_barrier (x=0x2b0330a318e0, flags=
      {is_write = 0, is_fp = 0, is_branch = 0, is_and = 0, is_or = 0,
is_sibcall = 0}, pred=0) at
/space/rguenther/src/svn/trunk/gcc/config/ia64/ia64.c:5775
#6  0x0000000000d71d3c in group_barrier_needed (insn=0x2b033094dfa0)
    at /space/rguenther/src/svn/trunk/gcc/config/ia64/ia64.c:6089
#7  0x0000000000d7209c in emit_all_insn_group_barriers (dump=0x0)
    at /space/rguenther/src/svn/trunk/gcc/config/ia64/ia64.c:6222
#8  0x0000000000d76da5 in ia64_reorg ()


-- 
           Summary: ICE in rws_insn_set, at config/ia64/ia64.c:5335
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org
GCC target triplet: ia64-*-*


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


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

* [Bug target/34637] ICE in rws_insn_set, at config/ia64/ia64.c:5335
  2008-01-02  9:58 [Bug target/34637] New: ICE in rws_insn_set, at config/ia64/ia64.c:5335 rguenth at gcc dot gnu dot org
@ 2008-01-02 10:11 ` rguenth at gcc dot gnu dot org
  2008-01-02 10:12 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-02 10:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-01-02 10:03 -------
*** Bug 34638 has been marked as a duplicate of this bug. ***


------- Comment #2 from rguenth at gcc dot gnu dot org  2008-01-02 10:04 -------
*** Bug 34639 has been marked as a duplicate of this bug. ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.1.3 4.3.0


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


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

* [Bug target/34637] ICE in rws_insn_set, at config/ia64/ia64.c:5335
  2008-01-02  9:58 [Bug target/34637] New: ICE in rws_insn_set, at config/ia64/ia64.c:5335 rguenth at gcc dot gnu dot org
  2008-01-02 10:11 ` [Bug target/34637] " rguenth at gcc dot gnu dot org
@ 2008-01-02 10:12 ` rguenth at gcc dot gnu dot org
  2008-01-02 10:13 ` rguenth at gcc dot gnu dot org
  2008-01-11 21:51 ` wilson at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-02 10:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-01-02 10:03 -------
*** Bug 34638 has been marked as a duplicate of this bug. ***


------- Comment #2 from rguenth at gcc dot gnu dot org  2008-01-02 10:04 -------
*** Bug 34639 has been marked as a duplicate of this bug. ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.1.3 4.3.0


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


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

* [Bug target/34637] ICE in rws_insn_set, at config/ia64/ia64.c:5335
  2008-01-02  9:58 [Bug target/34637] New: ICE in rws_insn_set, at config/ia64/ia64.c:5335 rguenth at gcc dot gnu dot org
  2008-01-02 10:11 ` [Bug target/34637] " rguenth at gcc dot gnu dot org
  2008-01-02 10:12 ` rguenth at gcc dot gnu dot org
@ 2008-01-02 10:13 ` rguenth at gcc dot gnu dot org
  2008-01-11 21:51 ` wilson at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-02 10:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-01-02 10:03 -------
*** Bug 34638 has been marked as a duplicate of this bug. ***


------- Comment #2 from rguenth at gcc dot gnu dot org  2008-01-02 10:04 -------
*** Bug 34639 has been marked as a duplicate of this bug. ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.1.3 4.3.0


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


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

* [Bug target/34637] ICE in rws_insn_set, at config/ia64/ia64.c:5335
  2008-01-02  9:58 [Bug target/34637] New: ICE in rws_insn_set, at config/ia64/ia64.c:5335 rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-01-02 10:13 ` rguenth at gcc dot gnu dot org
@ 2008-01-11 21:51 ` wilson at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: wilson at gcc dot gnu dot org @ 2008-01-11 21:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from wilson at gcc dot gnu dot org  2008-01-11 21:23 -------
The ia64 code to insert stop bits has a built-in assumption that if we see a
register set twice in the same instruction, then we goofed, and must ICE.

The testcase has an extended asm with 3 outputs and 4 inputs.  None of the
outputs are used after the asm.  The register allocator decided to assign two
of the outputs to the same hard register which is OK if they are never used. 
But they are used inside the asm, so this won't work.  If I mark the outputs as
early clobber, i.e. change
       : "=r" (compare_value) ,
       "=r" (exchange_value) ,
       "=r" (sum)
to
       : "=&r" (compare_value) ,
       "=&r" (exchange_value) ,
       "=&r" (sum)
Then there is no ICE, and I also get correct code.

So we need to fix the asm at a minimum.  It doesn't appear to be from gcc code.

We might also need to fix the ia64 backend to allow the same reg to be written
twice by the same insn, since it can occur as this testcase shows. Though this
testcase is broken, there might be some valid way that this can occur.  Maybe
just allowing this for asms is OK.  Or maybe just emitting a friendlier error
message here is OK.

That was for mainline.  I checked the gcc-4.1 branch, and this is the same
problem, except that all 3 outputs got assigned to the same hard register.


-- 

wilson at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wilson at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-01-11 21:23:40
               date|                            |


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


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

end of thread, other threads:[~2008-01-11 21:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-02  9:58 [Bug target/34637] New: ICE in rws_insn_set, at config/ia64/ia64.c:5335 rguenth at gcc dot gnu dot org
2008-01-02 10:11 ` [Bug target/34637] " rguenth at gcc dot gnu dot org
2008-01-02 10:12 ` rguenth at gcc dot gnu dot org
2008-01-02 10:13 ` rguenth at gcc dot gnu dot org
2008-01-11 21:51 ` wilson at gcc dot gnu dot 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).