[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

--- Comment #10 from Jakub Jelinek  ---
Author: jakub
Date: Wed Apr 13 12:26:26 2016
New Revision: 234933

URL: https://gcc.gnu.org/viewcvs?rev=234933=gcc=rev
Log:
PR debug/70628
* rtl.h (convert_memory_address_addr_space_1): New prototype.
* explow.c (convert_memory_address_addr_space_1): No longer static,
add NO_EMIT argument and don't call convert_modes if true, pass
it down recursively, remove break after return.
(convert_memory_address_addr_space): Adjust caller.
* simplify-rtx.c (simplify_unary_operation_1): Call
convert_memory_address_addr_space_1 instead of convert_memory_address,
if it returns NULL, don't simplify.

* gcc.dg/torture/pr70628.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/torture/pr70628.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/explow.c
trunk/gcc/rtl.h
trunk/gcc/simplify-rtx.c
trunk/gcc/testsuite/ChangeLog

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-13 Thread jiwang at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

Jiong Wang  changed:

   What|Removed |Added

 CC||jiwang at gcc dot gnu.org

--- Comment #9 from Jiong Wang  ---
(In reply to Jakub Jelinek from comment #7)
> Created attachment 38242 [details]
> gcc6-pr70628.patch
> 
> IMNSHO simplify-rtx.c should never generate instructions, it carefully uses
> gen_lowpart_no_emit hook instead of gen_lowpart etc., but the
> convert_memory_addr seems to be the only cases which violate this.


And looks to me postreload is doing uncessary transformation.

AArch64 failed the following check in reload_cse_simplify_operands:

  if (MEM_P (op)
  && GET_MODE_BITSIZE (GET_MODE (op)) < BITS_PER_WORD
  && LOAD_EXTEND_OP (GET_MODE (op)) != UNKNOWN)
{

because for ILP32, we still define UNITS_PER_WORD to be 8, while x86 defined
that to be 4, thus AArch64 triggered those "make the extension explicit" code,
and trying to transform

(insn 341 111 108 12 (set (reg/f:SI 0 x0 [189])
(mem/c:SI (plus:DI (reg/f:DI 29 x29)
(const_int 104 [0x68])) [5 %sfp+-8 S4 A32])) bug-1.c:23 49
{*movsi_aarch64}
 (nil))

into:

(insn 341 111 108 12 (set (reg:DI 0 x0)
(zero_extend:DI (mem/c:SI (plus:DI (reg/f:DI 29 x29)
(const_int 104 [0x68])) [5 %sfp+-8 S4 A32]))) bug-1.c:23 84
{*zero_extendsidi2_aarch64}
 (nil))

which looks uncessary to me.

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-12 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

--- Comment #8 from ktkachov at gcc dot gnu.org ---
(In reply to Jakub Jelinek from comment #7)
> Created attachment 38242 [details]
> gcc6-pr70628.patch
> 
> IMNSHO simplify-rtx.c should never generate instructions, it carefully uses
> gen_lowpart_no_emit hook instead of gen_lowpart etc., but the
> convert_memory_addr seems to be the only cases which violate this.

The patch passed bootstrap on aarch64 but fails with a -Werror warning on
armhf:
gcc/explow.c:269:15: error: unused parameter 'no_emit'
[-Werror=unused-parameter]
  bool no_emit)
   ^~~

This is because arm doesn't define POINTERS_EXTEND_UNSIGNED so the new
parameter no_emit is seen as unused.

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek  ---
Created attachment 38242
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38242=edit
gcc6-pr70628.patch

IMNSHO simplify-rtx.c should never generate instructions, it carefully uses
gen_lowpart_no_emit hook instead of gen_lowpart etc., but the
convert_memory_addr seems to be the only cases which violate this.

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-12 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

--- Comment #6 from ktkachov at gcc dot gnu.org ---
The ICE in cselib occurs when it calls gen_reg_rtx after reload, which is not
allowed.

This is through a call to simplify_unary_operation_1 on
(zero_extend:DI (high:SI (symbol_ref/f:SI ("*.LC3") [flags 0x82] )))

and more specifically a call to convert_memory_address here:

1594 #if defined(POINTERS_EXTEND_UNSIGNED)
1595   /* As we do not know which address space the pointer is referring
to,
1596  we can do this only if the target does not support different
pointer
1597  or address modes depending on the address space.  */
1598   if (target_default_pointer_address_modes_p ()
1599   && POINTERS_EXTEND_UNSIGNED > 0
1600   && mode == Pmode && GET_MODE (op) == ptr_mode
1601   && (CONSTANT_P (op)
1602   || (GET_CODE (op) == SUBREG
1603   && REG_P (SUBREG_REG (op))
1604   && REG_POINTER (SUBREG_REG (op))
1605   && GET_MODE (SUBREG_REG (op)) == Pmode))
1606   && !targetm.have_ptr_extend ())
1607 return convert_memory_address (Pmode, op);
1608 #endif

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-11 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

Andrew Pinski  changed:

   What|Removed |Added

 CC||pinskia at gcc dot gnu.org
   Target Milestone|--- |5.4

--- Comment #5 from Andrew Pinski  ---
(In reply to Andreas Schwab from comment #2)
> a714a09ad18ee606064bbaac690ab1c8121dcc31 is the first bad commit
> commit a714a09ad18ee606064bbaac690ab1c8121dcc31
> Author: mkuvyrkov 
> Date:   Fri Oct 24 08:22:12 2014 +
> 
> git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216620
> 138bc75d-0d04-0410-961f-82ee72b054a4

Since that is just a scheduler change, it exposes the latent bug.  Now the
problem is most likely related to Pmode != ptrmode (this is correct here but
the var-tracking code does not do the correct thing).

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-11 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

ktkachov at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-04-11
 CC||ktkachov at gcc dot gnu.org
 Ever confirmed|0   |1
  Known to fail||5.3.1, 6.0

--- Comment #4 from ktkachov at gcc dot gnu.org ---
Confirmed on 5.3 and trunk.
The reduced testcase for me is:
struct mntent
{
  char mnt_fsname;
  char mnt_opts;
} * a;

void gp_port_info_set_type ();

char *strstr ();

int *setmntent ();

struct mntent *getmntent ();

void
gp_port_library_list_mntent_1 (int p1)
{
  int *b = setmntent ();
  while (a = getmntent (b))
if (strstr ("") || strstr () || strstr ("fuse") || strstr ("nfs")
|| strstr ("autofs") || strstr ("devtmpfs") || strstr ("devpts")
|| strstr ("sysfs") || strstr ("gphotofs")
|| strstr (gp_port_library_list_mntent_1, "autofs")
|| strstr (gp_port_library_list_mntent_1, "nfs") || a->mnt_opts)
  if (strstr (>mnt_fsname))
gp_port_info_set_type (p1);
  getmntent (b);
  if (strstr ("") || strstr ("fuse") || strstr ("nfs") || strstr ("autofs")
  || strstr () || strstr ("devtmpfs") || strstr ("devpts")
  || strstr ("sysfs") || strstr ("gphotofs") || strstr (a, "autofs", ""))
gp_port_info_set_type ();
}

ICEs with -O2 -g -S -mabi=ilp32.

Funnily enough this reduced testcase ICEs on 4.9 as well but in a completely
different way in tree_ssa_dse.

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-11 Thread sch...@linux-m68k.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

--- Comment #3 from Andreas Schwab  ---
Created attachment 38239
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38239=edit
auto-host.h

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-11 Thread sch...@linux-m68k.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

Andreas Schwab  changed:

   What|Removed |Added

 CC||mkuvyrkov at gcc dot gnu.org

--- Comment #2 from Andreas Schwab  ---
a714a09ad18ee606064bbaac690ab1c8121dcc31 is the first bad commit
commit a714a09ad18ee606064bbaac690ab1c8121dcc31
Author: mkuvyrkov 
Date:   Fri Oct 24 08:22:12 2014 +

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216620
138bc75d-0d04-0410-961f-82ee72b054a4

[Bug debug/70628] [5/6 regression] ICE in get_reg_rtx, at emit-rtl.c:1025

2016-04-11 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70628

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek  ---
Can't reproduce with a current trunk's cross, can you attach your auto-host.h ?