public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
@ 2013-01-04 15:12 vries at gcc dot gnu.org
  2013-01-04 15:23 ` [Bug target/55876] " vries at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2013-01-04 15:12 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55876
           Summary: internal compiler error: in gen_rtx_SUBREG, at
                    emit-rtl.c:776
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vries@gcc.gnu.org


test.c:
...
static inline unsigned char
bar (const char *b)
{
   unsigned char used = 0;
   int i;

   for (i = 0; i < 4; ++i)
     if (b[i] != 'F')
       used = 1;

   return used;
}

static char buffer[8];

unsigned char
foo (void)
{
  return bar (buffer) ? 0 : 1;
}
...

...
$ ./install/bin/mips-linux-gnu-gcc -O3 test.c -S -mabi=64 -march=mips64 
test.c: In function 'foo':
test.c:19:3: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
   return bar (buffer) ? 0 : 1;
   ^
0x8394d8b gen_rtx_SUBREG(machine_mode, rtx_def*, int)
        gcc/emit-rtl.c:776
0x85d7da4 widen_operand
        gcc/optabs.c:333
0x85d927d expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*,
int, optab_methods)
        gcc/optabs.c:1648
0x83ce84a expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
        gcc/expr.c:9051
0x83d5d09 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**)
        gcc/expr.c:10426
0x83d5dc8 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**)
        gcc/expr.c:7848
0x83cf3f5 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**)
        gcc/expr.c:9211
0x83d5dc8 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**)
        gcc/expr.c:7848
0x86bbe63 expand_expr
        gcc/expr.h:444
0x86bf98f expand_return(tree_node*)
        gcc/stmt.c:1546
0x82d78a3 expand_gimple_stmt_1
        gcc/cfgexpand.c:2183
0x82d7e11 expand_gimple_stmt
        gcc/cfgexpand.c:2305
0x82d8f36 expand_gimple_basic_block
        gcc/cfgexpand.c:4084
0x82d9d13 gimple_expand_cfg
        gcc/cfgexpand.c:4603
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
...

configure line:
...
$ ./install/bin/mips-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=./install/bin/mips-linux-gnu-gcc
COLLECT_LTO_WRAPPER=install/bin/../libexec/gcc/mips-linux-gnu/4.8.0/lto-wrapper
Target: mips-linux-gnu
Configured with: src/gcc-mainline/configure --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=mips-linux-gnu --enable-threads
--disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as
--with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-lto
--enable-symvers=gnu --enable-__cxa_atexit --disable-nls
--prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/mips-linux-gnu/libc
--with-build-sysroot=install/mips-linux-gnu/libc
--with-gmp=obj/pkg-mainline-0-mips-linux-gnu/fsf-mainline-0-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr
--with-mpfr=obj/pkg-mainline-0-mips-linux-gnu/fsf-mainline-0-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr
--with-mpc=obj/pkg-mainline-0-mips-linux-gnu/fsf-mainline-0-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-isl=obj/pkg-mainline-0-mips-linux-gnu/fsf-mainline-0-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr
--with-cloog=obj/pkg-mainline-0-mips-linux-gnu/fsf-mainline-0-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr
--with-libelf=obj/pkg-mainline-0-mips-linux-gnu/fsf-mainline-0-mips-linux-gnu.extras/host-libs-i686-pc-linux-gnu/usr
--disable-libgomp --disable-libitm --enable-poison-system-directories
--with-build-time-tools=install/mips-linux-gnu/bin
--with-build-time-tools=install/mips-linux-gnu/bin
Thread model: posix
gcc version 4.8.0 20130104 (experimental) (GCC) 
...


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

* [Bug target/55876] internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
  2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
@ 2013-01-04 15:23 ` vries at gcc dot gnu.org
  2013-01-04 16:00 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2013-01-04 15:23 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from vries at gcc dot gnu.org 2013-01-04 15:23:25 UTC ---
while expanding the xor, we try to widen an DImode reg from QImode to SImode:
...
#6  0x085d7da5 in widen_operand (op=0xf7cd2ec0, mode=SImode, oldmode=QImode,
unsignedp=1, no_extend=1) at src/gcc-mainline/gcc/optabs.c:333
333         return gen_rtx_SUBREG (mode, force_reg (GET_MODE (op), op), 0);
(gdb) l
328         return convert_modes (mode, oldmode, op, unsignedp);
329
330       /* If MODE is no wider than a single word, we return a paradoxical
331          SUBREG.  */
332       if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
333         return gen_rtx_SUBREG (mode, force_reg (GET_MODE (op), op), 0);
334
335       /* Otherwise, get an object of MODE, clobber it, and set the
low-order
336          part to OP.  */
337
(gdb) call debug_rtx (op)
(reg:DI 222 [ used+-7 ])
...

Just before expand, the representation looks like:
...
foo ()
{
  unsigned charD.13 usedD.1407;
  charD.2 _7;
  unsigned charD.13 _13;
  charD.2 _19;
  charD.2 _28;
  charD.2 _37;

;;   basic block 2, loop depth 0
;;    pred:       ENTRY
  # VUSE <.MEM_1(D)>
  _19 = MEM[(const charD.2 *)&bufferD.1387];
  used_20 = _19 != 70 ? 1 : 0;
  # VUSE <.MEM_1(D)>
  _28 = MEM[(const charD.2 *)&bufferD.1387 + 1B];
  used_29 = _28 == 70 ? used_20 : 1;
  # VUSE <.MEM_1(D)>
  _37 = MEM[(const charD.2 *)&bufferD.1387 + 2B];
  used_38 = _37 == 70 ? used_29 : 1;
  # VUSE <.MEM_1(D)>
  _7 = MEM[(const charD.2 *)&bufferD.1387 + 3B];
  used_10 = _7 == 70 ? used_38 : 1;
  _13 = used_10 ^ 1;
  # VUSE <.MEM_1(D)>
  return _13;
;;    succ:       EXIT

}
...

The reason that used_10 is in a DImode reg is because
  used_10 = _7 == 70 ? used_38 : 1
and the all the other conditional moves before are promoted by
expand_cond_expr_using_cmove.


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

* [Bug target/55876] internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
  2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
  2013-01-04 15:23 ` [Bug target/55876] " vries at gcc dot gnu.org
@ 2013-01-04 16:00 ` vries at gcc dot gnu.org
  2013-01-04 16:43 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2013-01-04 16:00 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from vries at gcc dot gnu.org 2013-01-04 16:00:07 UTC ---
This patch introduces an assert that triggers before rather than during
gen_rtx_SUBREG:
...
Index: optabs.c
===================================================================
--- optabs.c (revision 194898)
+++ optabs.c (working copy)
@@ -330,7 +330,12 @@ widen_operand (rtx op, enum machine_mode
   /* If MODE is no wider than a single word, we return a paradoxical
      SUBREG.  */
   if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
-    return gen_rtx_SUBREG (mode, force_reg (GET_MODE (op), op), 0);
+    {
+      /* Check that the result is a paradoxical subreg (outer mode strictly
+        larger than inner mode.  */
+      gcc_assert (GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (op)));
+      return gen_rtx_SUBREG (mode, force_reg (GET_MODE (op), op), 0);
+    }

   /* Otherwise, get an object of MODE, clobber it, and set the low-order
      part to OP.  */
...

This assert allows triggers both with -EB and -EL, while the original assert
only triggers with -EB.


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

* [Bug target/55876] internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
  2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
  2013-01-04 15:23 ` [Bug target/55876] " vries at gcc dot gnu.org
  2013-01-04 16:00 ` vries at gcc dot gnu.org
@ 2013-01-04 16:43 ` vries at gcc dot gnu.org
  2013-01-07 10:21 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2013-01-04 16:43 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from vries at gcc dot gnu.org 2013-01-04 16:42:36 UTC ---
Another way to go about it is to prevent the assert from triggering:
...
Index: optabs.c
===================================================================
--- optabs.c (revision 194898)
+++ optabs.c (working copy)
@@ -329,7 +329,8 @@ widen_operand (rtx op, enum machine_mode

   /* If MODE is no wider than a single word, we return a paradoxical
      SUBREG.  */
-  if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
+  if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
+      && GET_MODE_SIZE (mode) > GET_MODE_SIZE (GET_MODE (op)))
     return gen_rtx_SUBREG (mode, force_reg (GET_MODE (op), op), 0);

   /* Otherwise, get an object of MODE, clobber it, and set the low-order
     part to OP.  */
...

The generated code seems to be ok:
...
(insn 34 33 35 (clobber (reg:SI 228)) -1
     (nil))

(insn 35 34 36 (set (subreg:DI (reg:SI 228) 0)
    (reg:DI 222 [ usedD.1407 ])) -1
     (nil))

(insn 36 35 37 (set (reg:SI 229)
    (xor:SI (reg:SI 228)
        (const_int 1 [0x1]))) -1
     (nil))
...

But I'm not sure this is the proper location to fix this.


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

* [Bug target/55876] internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
  2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-01-04 16:43 ` vries at gcc dot gnu.org
@ 2013-01-07 10:21 ` vries at gcc dot gnu.org
  2013-01-15 17:25 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2013-01-07 10:21 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from vries at gcc dot gnu.org 2013-01-07 10:20:52 UTC ---
> Another way to go about it is to prevent the assert from triggering:

Tested and submitted fix:
http://gcc.gnu.org/ml/gcc-patches/2013-01/msg00288.html


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

* [Bug target/55876] internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
  2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-01-07 10:21 ` vries at gcc dot gnu.org
@ 2013-01-15 17:25 ` vries at gcc dot gnu.org
  2013-05-25  8:29 ` rsandifo at gcc dot gnu.org
  2013-05-25  8:42 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2013-01-15 17:25 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from vries at gcc dot gnu.org 2013-01-15 17:25:05 UTC ---
Author: vries
Date: Tue Jan 15 17:24:55 2013
New Revision: 195212

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195212
Log:
2013-01-15  Tom de Vries  <tom@codesourcery.com>

    PR target/55876
    * optabs.c (widen_operand): Use gen_lowpart instead of gen_rtx_SUBREG.
    Update comment.

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


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

* [Bug target/55876] internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
  2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-01-15 17:25 ` vries at gcc dot gnu.org
@ 2013-05-25  8:29 ` rsandifo at gcc dot gnu.org
  2013-05-25  8:42 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2013-05-25  8:29 UTC (permalink / raw)
  To: gcc-bugs

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

rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsandifo at gcc dot gnu.org

--- Comment #6 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Patch applied in the 4.8 timeframe.  Thanks Tom.


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

* [Bug target/55876] internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776
  2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-05-25  8:29 ` rsandifo at gcc dot gnu.org
@ 2013-05-25  8:42 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2013-05-25  8:42 UTC (permalink / raw)
  To: gcc-bugs

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

vries at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |vries at gcc dot gnu.org

--- Comment #7 from vries at gcc dot gnu.org ---
Marking fixed


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

end of thread, other threads:[~2013-05-25  8:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-04 15:12 [Bug target/55876] New: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.c:776 vries at gcc dot gnu.org
2013-01-04 15:23 ` [Bug target/55876] " vries at gcc dot gnu.org
2013-01-04 16:00 ` vries at gcc dot gnu.org
2013-01-04 16:43 ` vries at gcc dot gnu.org
2013-01-07 10:21 ` vries at gcc dot gnu.org
2013-01-15 17:25 ` vries at gcc dot gnu.org
2013-05-25  8:29 ` rsandifo at gcc dot gnu.org
2013-05-25  8:42 ` vries 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).