Bug 53961 - internal compiler error: in memory_address_length, at config/i386/i386.c:23341
Summary: internal compiler error: in memory_address_length, at config/i386/i386.c:23341
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.1
: P3 major
Target Milestone: 4.7.2
Assignee: Uroš Bizjak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-14 11:31 UTC by wbrana
Modified: 2012-08-02 16:30 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-07-14 00:00:00


Attachments
source code (35.19 KB, application/octet-stream)
2012-07-14 15:14 UTC, wbrana
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wbrana 2012-07-14 11:31:33 UTC
see https://bugs.gentoo.org/show_bug.cgi?id=426572
Comment 1 Steven Bosscher 2012-07-14 14:46:40 UTC
Please provide a test case, not a link.
Comment 2 wbrana 2012-07-14 15:14:18 UTC
Created attachment 27788 [details]
source code

/usr/bin/gcc:     file format elf32-x86-64

 gcc -m64 -O2 -c ./host_ppc_isel.i -o test.o
In file included from priv/host_ppc_isel.c:37:0:
../VEX/pub/libvex_basictypes.h: In function 'Ptr_to_ULong':
../VEX/pub/libvex_basictypes.h:195:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
../VEX/pub/libvex_basictypes.h: In function 'ULong_to_Ptr':
../VEX/pub/libvex_basictypes.h:200:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
priv/host_ppc_isel.c: In function 'iselInt64Expr':
priv/host_ppc_isel.c:2834:1: internal compiler error: in memory_address_length, at config/i386/i386.c:23341
Comment 3 Uroš Bizjak 2012-07-14 19:13:57 UTC
The testcase works for me with:

GNU C (GCC) version 4.7.2 20120713 (prerelease) [gcc-4_7-branch revision 189471] (x86_64-unknown-linux-gnu)

and 4.8.0.
Comment 4 wbrana 2012-07-14 19:22:16 UTC
Are you using X32 GCC binary?
Comment 5 Andrew Pinski 2012-07-14 20:13:18 UTC
(In reply to comment #4)
> Are you using X32 GCC binary?

So -mx32 makes it fail or rather GCC defaulting to x32 makes it fail?
Comment 6 wbrana 2012-07-14 20:17:23 UTC
if gcc is compiled as X32 
/usr/bin/gcc:     file format elf32-x86-64

and command 
gcc -m64 -O2 -c ./host_ppc_isel.i -o test.o
Comment 7 H.J. Lu 2012-07-14 21:10:28 UTC
It is fixed on trunk.  It is on 4.7 branch as of revision 189343.
Comment 8 H.J. Lu 2012-07-14 21:19:01 UTC
This address:

(gdb) call debug_rtx (addr)
(and:DI (symbol_ref:DI ("h_DPBtoBCD") [flags 0x41] <function_decl 0x7ffff1b8b400 h_DPBtoBCD>)
    (const_int 4294967295 [0xffffffff]))
(gdb) 

triggers ICE.
Comment 9 Uroš Bizjak 2012-07-14 21:48:32 UTC
Can you test following patch that prevents non-register AND address operands:

--cut here--
Index: i386.c
===================================================================
--- i386.c      (revision 189483)
+++ i386.c      (working copy)
@@ -11591,7 +11591,8 @@ ix86_decompose_address (rtx addr, struct ix86_addr
          if (GET_CODE (addr) == SUBREG
              && GET_MODE (SUBREG_REG (addr)) == SImode)
            addr = SUBREG_REG (addr);
-         else if (GET_MODE (addr) == DImode)
+         else if (REG_P (addr)
+                  && GET_MODE (addr) == DImode)
            addr = gen_rtx_SUBREG (SImode, addr, 0);
          else if (GET_MODE (addr) != VOIDmode)
            return 0;
--cut here--
Comment 10 H.J. Lu 2012-07-14 22:36:57 UTC
This only happens on hjl/x32/gcc-4_7-branch branch.
Comment 11 H.J. Lu 2012-07-14 22:46:29 UTC
(In reply to comment #9)
> Can you test following patch that prevents non-register AND address operands:
> 
> --cut here--
> Index: i386.c
> ===================================================================
> --- i386.c      (revision 189483)
> +++ i386.c      (working copy)
> @@ -11591,7 +11591,8 @@ ix86_decompose_address (rtx addr, struct ix86_addr
>           if (GET_CODE (addr) == SUBREG
>               && GET_MODE (SUBREG_REG (addr)) == SImode)
>             addr = SUBREG_REG (addr);
> -         else if (GET_MODE (addr) == DImode)
> +         else if (REG_P (addr)
> +                  && GET_MODE (addr) == DImode)
>             addr = gen_rtx_SUBREG (SImode, addr, 0);
>           else if (GET_MODE (addr) != VOIDmode)
>             return 0;
> --cut here--

It doesn't work.  I will find which checkin on trunk fixed this.
Comment 12 H.J. Lu 2012-07-14 23:53:22 UTC
It is fixed by revision 186839:

http://gcc.gnu.org/ml/gcc-cvs/2012-04/msg00791.html

on trunk.
Comment 13 uros 2012-07-15 08:13:57 UTC
Author: uros
Date: Sun Jul 15 08:13:47 2012
New Revision: 189491

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189491
Log:
	PR target/53961

	Backport from mainline
	2012-04-25  Jakub Jelinek  <jakub@redhat.com>

	PR target/53110
	* config/i386/i386.md (and<mode>3): For andq $0xffffffff, reg
	instead expand it as zero extension.


Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/i386/i386.md
Comment 14 Uroš Bizjak 2012-07-15 08:16:49 UTC
Fixed.
Comment 15 H.J. Lu 2012-07-15 13:48:18 UTC
I synced hjl/x32/gcc-4_7-branch with gcc-4_7-branch.
Comment 16 Uroš Bizjak 2012-07-16 08:44:29 UTC
.
Comment 17 uros 2012-07-22 15:44:55 UTC
Author: uros
Date: Sun Jul 22 15:44:51 2012
New Revision: 189756

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189756
Log:
	PR target/53961
	* config/i386/i386.md (*lea): New insn pattern.
	(*lea_1): Remove.
	(*lea<mode>_2): Ditto.
	(*lea_{3,4,5,6}_zext): Ditto.
	* config/i386/constraints.md (j): Remove address constraint.
	* config/i386/i386.c (ix86_decompose_address): Allow SImode subreg
	of an address.
	(ix86_print_operand_address): Handle SImode subreg of an address.
	(ix86_avoid_lea_for_add): Reject zero-extended addresses for now.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/constraints.md
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/i386/i386.md
    trunk/gcc/config/i386/predicates.md
Comment 18 uros 2012-07-23 16:04:30 UTC
Author: uros
Date: Mon Jul 23 16:04:23 2012
New Revision: 189787

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189787
Log:
	PR target/53961
	* config/i386/i386.md (*lea): Add asserts to detect invalid addresses.
	* config/i386/i386.c (ix86_print_operand_address): Ditto.
	(ix86_decompose_address): Allow (zero_extend:DI (subreg:SI (...)))
	addresses.  Prevent zero extensions of CONST_INT operands.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/i386/i386.md
Comment 19 uros 2012-07-24 11:37:24 UTC
Author: uros
Date: Tue Jul 24 11:37:20 2012
New Revision: 189806

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189806
Log:
	PR target/53961
	* config/i386/i386.c (ix86_legitimate_address_p): Move check for
	negative constant address for TARET_X32 ...
	(ix86_decompose_address): ... here.  Reject constant addresses
	that don't satisfy x86_64_immediate_operand predicate.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/i386/i386.md
Comment 20 Uroš Bizjak 2012-07-24 16:18:33 UTC
These patches, and the patch for PR52530, should be backported to 4.7.2
Comment 21 uros 2012-08-02 16:24:35 UTC
Author: uros
Date: Thu Aug  2 16:24:25 2012
New Revision: 190089

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190089
Log:
	Backport from mainline
	2012-07-24  Uros Bizjak  <ubizjak@gmail.com>

	PR target/53961
	* config/i386/i386.c (ix86_legitimate_address_p): Move check for
	negative constant address for TARGET_X32 ...
	(ix86_decompose_address): ... here.  Reject constant addresses
	that don't satisfy x86_64_immediate_operand predicate.

	2012-07-23  Uros Bizjak  <ubizjak@gmail.com>

	PR target/53961
	* config/i386/i386.md (*lea): Add asserts to detect invalid addresses.
	* config/i386/i386.c (ix86_print_operand_address): Ditto.
	(ix86_decompose_address): Allow (zero_extend:DI (subreg:SI (...)))
	addresses.  Prevent zero extensions of CONST_INT operands.

	2012-07-22  Uros Bizjak  <ubizjak@gmail.com>

	PR target/53961
	* config/i386/i386.md (*lea): New insn pattern.
	(*lea_1): Remove.
	(*lea<mode>_2): Ditto.
	(*lea_{3,4,5,6}_zext): Ditto.
	* config/i386/predicates.md (lea_address_operand): Do not reject
	zero-extended address operands.
	* config/i386/constraints.md (j): Remove address constraint.
	* config/i386/i386.c (ix86_decompose_address): Allow SImode subreg
	of an address.
	(ix86_print_operand_address): Handle SImode subreg of an address.
	(ix86_avoid_lea_for_addr): Reject zero-extended addresses for now.


Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/i386/constraints.md
    branches/gcc-4_7-branch/gcc/config/i386/i386.c
    branches/gcc-4_7-branch/gcc/config/i386/i386.md
    branches/gcc-4_7-branch/gcc/config/i386/predicates.md
Comment 22 Uroš Bizjak 2012-08-02 16:30:39 UTC
Fixed everywhere.