Bug 47364 - [x32] internal compiler error: in emit_move_insn, at expr.c:3355
Summary: [x32] internal compiler error: in emit_move_insn, at expr.c:3355
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 47812 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-01-19 20:41 UTC by H.J. Lu
Modified: 2011-08-05 22:05 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-01-19 20:41:52 UTC
On x32 branch, revision 169022 gave me:

[hjl@gnu-6 ilp32-6]$ cat l.i
static unsigned char foo[256];

arc4_init(void)
{
  int n;

  for (n = 0; n < 256; n++)
    foo[n] = n;
}
...

Starting program: /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/cc1 -fpreprocessed l.i -quiet -dumpbase l.i -mx32 -mtune=generic -march=x86-64 -auxbase-strip l.s -O -version -fPIC -o l.s
GNU C (GCC) version 4.6.0 20110119 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.6.0 20110119 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 907bc1978bdfb9cacc592629d3ab71fe

Breakpoint 1, fancy_abort (
    file=0x11f1068 "/export/gnu/import/git/gcc-x32/gcc/expr.c", line=3355, 
    function=0x11f2526 "emit_move_insn")
    at /export/gnu/import/git/gcc-x32/gcc/diagnostic.c:893
893	  internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
(gdb) bt
#0  fancy_abort (file=0x11f1068 "/export/gnu/import/git/gcc-x32/gcc/expr.c", 
    line=3355, function=0x11f2526 "emit_move_insn")
    at /export/gnu/import/git/gcc-x32/gcc/diagnostic.c:893
#1  0x00000000006f074b in emit_move_insn (x=0x7ffff1af4bc0, y=0x7ffff1af4aa0)
    at /export/gnu/import/git/gcc-x32/gcc/expr.c:3354
#2  0x0000000000cda2b9 in ix86_legitimize_address (x=0x7ffff1af81f8, 
    oldx=0x7ffff1af81c8, mode=QImode)
    at /export/gnu/import/git/gcc-x32/gcc/config/i386/i386.c:12952
#3  0x00000000009ed580 in default_addr_space_legitimize_address (
    x=0x7ffff1af81f8, oldx=0x7ffff1af81c8, mode=QImode, as=0 '\000')
    at /export/gnu/import/git/gcc-x32/gcc/targhooks.c:1136
#4  0x00000000006d416b in memory_address_addr_space (mode=QImode, 
    x=0x7ffff1af81f8, as=0 '\000')
    at /export/gnu/import/git/gcc-x32/gcc/explow.c:457
#5  0x000000000070ba0e in expand_expr_real_1 (exp=0x7ffff1af60a0, target=0x0, 
    tmode=VOIDmode, modifier=EXPAND_WRITE, alt_rtl=0x0)
    at /export/gnu/import/git/gcc-x32/gcc/expr.c:8645
#6  0x0000000000704be3 in expand_expr_real (exp=0x7ffff1af60a0, target=0x0, 
    tmode=VOIDmode, modifier=EXPAND_WRITE, alt_rtl=0x0)
    at /export/gnu/import/git/gcc-x32/gcc/expr.c:7214
#7  0x00000000006e7863 in expand_expr (exp=0x7ffff1af60a0, target=0x0, 
    mode=VOIDmode, modifier=EXPAND_WRITE)
    at /export/gnu/import/git/gcc-x32/gcc/expr.h:422
Comment 1 hjl@gcc.gnu.org 2011-01-19 20:53:19 UTC
Author: hjl
Date: Wed Jan 19 20:53:14 2011
New Revision: 169029

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169029
Log:
Convert to Pmode if needed in ix86_legitimize_address.

gcc/

2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/47364
	* config/i386/i386.c (ix86_legitimize_address): Convert to
	Pmode if needed.

gcc/testsuite/

2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/47364
	* gcc.target/i386/pr47364.c: New.

Added:
    branches/x32/gcc/testsuite/ChangeLog.x32
    branches/x32/gcc/testsuite/gcc.target/i386/pr47364.c
Modified:
    branches/x32/gcc/ChangeLog.x32
    branches/x32/gcc/config/i386/i386.c
Comment 2 H.J. Lu 2011-01-19 21:02:01 UTC
Another one. On x32 branch, revision 169029 gave me:

[hjl@gnu-6 ilp32-7]$ cat x.c
extern __SIZE_TYPE__ strlen (const char *);
void foo (char *, const char *);
int bar (const char *prefix)
{
    char buff[256];
    foo (buff, prefix);
    return strlen(buff);
}
[hjl@gnu-6 ilp32-7]$ make
/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -S -o x.s -mx32 -O2   x.c
x.c: In function ‘bar’:
x.c:7:18: internal compiler error: in emit_move_insn, at expr.c:3355
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [x.s] Error 1
[hjl@gnu-6 ilp32-7]$ 

(gdb) r
Starting program: /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/cc1 -fpreprocessed foo.i -quiet -dumpbase foo.i -mx32 -mtune=generic -march=x86-64 -auxbase-strip foo.s -O2 -version -o foo.s
GNU C (GCC) version 4.6.0 20110119 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.6.0 20110119 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 2521805caa85b3824657bbc223b7b9f6

Breakpoint 1, fancy_abort (
    file=0x11f1128 "/export/gnu/import/git/gcc-x32/gcc/expr.c", line=3355, 
    function=0x11f25e6 "emit_move_insn")
    at /export/gnu/import/git/gcc-x32/gcc/diagnostic.c:893
893	  internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
(gdb) bt
#0  fancy_abort (file=0x11f1128 "/export/gnu/import/git/gcc-x32/gcc/expr.c", 
    line=3355, function=0x11f25e6 "emit_move_insn")
    at /export/gnu/import/git/gcc-x32/gcc/diagnostic.c:893
#1  0x00000000006f074b in emit_move_insn (x=0x7ffff1c92fc0, y=0x7ffff1c92d60)
    at /export/gnu/import/git/gcc-x32/gcc/expr.c:3354
#2  0x0000000000cef39f in ix86_expand_strlen (out=0x7ffff1c92fc0, 
    src=0x7ffff1af01b0, eoschar=0x7ffff1ba3470, align=0x7ffff1ba34f0)
    at /export/gnu/import/git/gcc-x32/gcc/config/i386/i386.c:21664
#3  0x0000000000ecf575 in gen_strlensi (operand0=0x7ffff1c92fc0, 
    operand1=0x7ffff1af01b0, operand2=0x7ffff1ba3470, operand3=0x7ffff1ba34f0)
    at /export/gnu/import/git/gcc-x32/gcc/config/i386/i386.md:16173
#4  0x00000000005ae5bd in expand_builtin_strlen (exp=0x7ffff1a985e8, 
    target=0x7ffff1c92fc0, target_mode=SImode)
    at /export/gnu/import/git/gcc-x32/gcc/builtins.c:3429
#5  0x00000000005bb501 in expand_builtin (exp=0x7ffff1a985e8, 
    target=0x7ffff1c92fc0, subtarget=0x0, mode=SImode, ignore=0)
    at /export/gnu/import/git/gcc-x32/gcc/builtins.c:6120
#6  0x00000000007102aa in expand_expr_real_1 (exp=0x7ffff1a985e8, 
    target=0x7ffff1c92fc0, tmode=SImode, modifier=EXPAND_NORMAL, 
    alt_rtl=0x7fffffffce00) at /export/gnu/import/git/gcc-x32/gcc/expr.c:9300
#7  0x0000000000704b9e in expand_expr_real (exp=0x7ffff1a985e8, 
    target=0x7ffff1c92fc0, tmode=SImode, modifier=EXPAND_NORMAL, 
    alt_rtl=0x7fffffffce00) at /export/gnu/import/git/gcc-x32/gcc/expr.c:7206
---Type <return> to continue, or q <return> to quit---
#8  0x00000000006f5eb7 in store_expr (exp=0x7ffff1a985e8, 
    target=0x7ffff1c92fc0, call_param_p=0, nontemporal=0 '\000')
    at /export/gnu/import/git/gcc-x32/gcc/expr.c:4674
#9  0x00000000006f437b in expand_assignment (to=0x7ffff1aa8160, 
    from=0x7ffff1a985e8, nontemporal=0 '\000')
    at /export/gnu/import/git/gcc-x32/gcc/expr.c:4447
#10 0x000000000060a896 in expand_call_stmt (stmt=0x7ffff1ba8380)
    at /export/gnu/import/git/gcc-x32/gcc/cfgexpand.c:1914
#11 0x000000000060a997 in expand_gimple_stmt_1 (stmt=0x7ffff1ba8380)
    at /export/gnu/import/git/gcc-x32/gcc/cfgexpand.c:1949
#12 0x000000000060b046 in expand_gimple_stmt (stmt=0x7ffff1ba8380)
    at /export/gnu/import/git/gcc-x32/gcc/cfgexpand.c:2108
#13 0x0000000000611b18 in expand_gimple_basic_block (bb=0x7ffff1a941a0)
    at /export/gnu/import/git/gcc-x32/gcc/cfgexpand.c:3570
#14 0x00000000006138e1 in gimple_expand_cfg ()
    at /export/gnu/import/git/gcc-x32/gcc/cfgexpand.c:4053
#15 0x00000000008f985f in execute_one_pass (pass=0x17aeda0)
    at /export/gnu/import/git/gcc-x32/gcc/passes.c:1561
#16 0x00000000008f9a4e in execute_pass_list (pass=0x17aeda0)
    at /export/gnu/import/git/gcc-x32/gcc/passes.c:1616
#17 0x0000000000a82714 in tree_rest_of_compilation (fndecl=0x7ffff1aa6100)
    at /export/gnu/import/git/gcc-x32/gcc/tree-optimize.c:422
#18 0x0000000000d228c9 in cgraph_expand_function (node=0x7ffff1aaa000)
---Type <return> to continue, or q <return> to quit---
    at /export/gnu/import/git/gcc-x32/gcc/cgraphunit.c:1522
#19 0x0000000000d22a88 in cgraph_expand_all_functions ()
    at /export/gnu/import/git/gcc-x32/gcc/cgraphunit.c:1581
#20 0x0000000000d230bd in cgraph_optimize ()
    at /export/gnu/import/git/gcc-x32/gcc/cgraphunit.c:1841
#21 0x0000000000d20bf0 in cgraph_finalize_compilation_unit ()
    at /export/gnu/import/git/gcc-x32/gcc/cgraphunit.c:1042
#22 0x00000000004aeb60 in c_write_global_declarations ()
    at /export/gnu/import/git/gcc-x32/gcc/c-decl.c:9843
#23 0x00000000009efd3e in compile_file ()
    at /export/gnu/import/git/gcc-x32/gcc/toplev.c:591
#24 0x00000000009f1e39 in do_compile ()
    at /export/gnu/import/git/gcc-x32/gcc/toplev.c:1874
#25 0x00000000009f1f86 in toplev_main (argc=15, argv=0x7fffffffdf08)
    at /export/gnu/import/git/gcc-x32/gcc/toplev.c:1937
#26 0x0000000000587bf0 in main (argc=15, argv=0x7fffffffdf08)
    at /export/gnu/import/git/gcc-x32/gcc/main.c:36
(gdb)
Comment 3 hjl@gcc.gnu.org 2011-01-19 21:38:37 UTC
Author: hjl
Date: Wed Jan 19 21:38:32 2011
New Revision: 169032

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169032
Log:
Properly handle Pmode != ptr_mode when expanding builtin strlen.

gcc/

2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/47364
	* builtins.c (expand_builtin_strlen): Convert to Pmode if PAT
	isn't in Pmode.

	* config/i386/i386.c (ix86_expand_strlen): Handle GET_MODE (out)
	!= Pmode.

gcc/testsuite/

2011-01-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/47364
	* gcc.target/i386/pr47364-2.c: New.

Added:
    branches/x32/gcc/testsuite/gcc.target/i386/pr47364-2.c
Modified:
    branches/x32/gcc/ChangeLog.x32
    branches/x32/gcc/builtins.c
    branches/x32/gcc/config/i386/i386.c
    branches/x32/gcc/testsuite/ChangeLog.x32
Comment 4 H.J. Lu 2011-02-19 14:22:45 UTC
*** Bug 47812 has been marked as a duplicate of this bug. ***
Comment 5 hjl@gcc.gnu.org 2011-02-19 14:53:24 UTC
Author: hjl
Date: Sat Feb 19 14:53:20 2011
New Revision: 170316

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170316
Log:
Properly handle target not in Pmode when expanding strlen.

gcc/

2011-02-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/47364
	* builtins.c (expand_builtin_strlen): Properly handle target
	not in Pmode.

gcc/testsuite/

2011-02-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/47364
	* gcc.dg/torture/pr47364-1.c: New.

Added:
    branches/x32/gcc/testsuite/gcc.dg/torture/pr47364-1.c
Modified:
    branches/x32/gcc/ChangeLog.x32
    branches/x32/gcc/builtins.c
    branches/x32/gcc/config/i386/i386.c
    branches/x32/gcc/testsuite/ChangeLog.x32
Comment 6 hjl@gcc.gnu.org 2011-04-02 05:45:55 UTC
Author: hjl
Date: Sat Apr  2 05:45:52 2011
New Revision: 171873

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171873
Log:
Only expand strlen to Pmode.

2011-03-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/47364
	* config/i386/i386.md (strlen<mode>): Replace SWI48x with P.

Modified:
    branches/x32/gcc/ChangeLog.x32
    branches/x32/gcc/config/i386/i386.md
Comment 7 hjl@gcc.gnu.org 2011-06-14 16:32:01 UTC
Author: hjl
Date: Tue Jun 14 16:31:57 2011
New Revision: 175034

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175034
Log:
Properly expand strlen to Pmode.

2011-06-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/47364
	* builtins.c (expand_builtin_strlen): Expand strlen to Pmode
	and properly handle result not in Pmode.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
Comment 8 hjl@gcc.gnu.org 2011-06-14 16:36:16 UTC
Author: hjl
Date: Tue Jun 14 16:36:12 2011
New Revision: 175035

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175035
Log:
Pass POINTERS_EXTEND_UNSIGNED to convert_to_mode.

2011-06-12  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/47364
	* builtins.c (expand_builtin_strlen): Properly handle target
	not in Pmode if POINTERS_EXTEND_UNSIGNED is defined.

Modified:
    branches/x32/gcc/ChangeLog.x32
    branches/x32/gcc/builtins.c
Comment 9 hjl@gcc.gnu.org 2011-06-14 16:36:50 UTC
Author: hjl
Date: Tue Jun 14 16:36:45 2011
New Revision: 175036

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175036
Log:
Expand strlen to Pmode.

2011-06-14  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/47364
	* builtins.c (expand_builtin_strlen): Expand strlen to Pmode.

Modified:
    branches/x32/gcc/ChangeLog.x32
    branches/x32/gcc/builtins.c
Comment 10 hjl@gcc.gnu.org 2011-07-28 12:32:29 UTC
Author: hjl
Date: Thu Jul 28 12:32:23 2011
New Revision: 176868

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176868
Log:
Only expand strlen to Pmode.

2011-07-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/47364
	* config/i386/i386.md (strlen<mode>): Replace SWI48x with P.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.md
Comment 11 hjl@gcc.gnu.org 2011-07-28 12:58:06 UTC
Author: hjl
Date: Thu Jul 28 12:58:00 2011
New Revision: 176869

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176869
Log:
Only expand strlen to Pmode.

2011-07-28  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline
	2011-07-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/47364
	* config/i386/i386.md (strlen<mode>): Replace SWI48x with P.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/i386/i386.md
Comment 12 H.J. Lu 2011-07-28 13:34:28 UTC
Fixed.
Comment 13 uros 2011-07-28 16:20:17 UTC
Author: uros
Date: Thu Jul 28 16:20:06 2011
New Revision: 176875

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176875
Log:
	PR target/47364
	* config/i386/i386.md (strlensi): Enable for !TARGET_64BIT only.
	(strlendi): Enable for TARGET_64BIT only.


Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/i386/i386.md
Comment 14 uros 2011-07-28 16:21:47 UTC
Author: uros
Date: Thu Jul 28 16:21:44 2011
New Revision: 176877

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176877
Log:
	PR target/47364
	* config/i386/i386.md (strlensi): Enable for !TARGET_64BIT only.
	(strlendi): Enable for TARGET_64BIT only.


Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/i386/i386.md
Comment 15 hjl@gcc.gnu.org 2011-08-05 22:05:45 UTC
Author: hjl
Date: Fri Aug  5 22:05:43 2011
New Revision: 177487

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177487
Log:
Add a testcase for PR middle-end/47364.

2011-08-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/47364
	* gcc.dg/torture/pr47364-1.c: New.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr47364-1.c
Modified:
    trunk/gcc/testsuite/ChangeLog