[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

--- Comment #7 from Jakub Jelinek jakub at gcc dot gnu.org ---
Author: jakub
Date: Tue May 13 08:28:53 2014
New Revision: 210352

URL: http://gcc.gnu.org/viewcvs?rev=210352root=gccview=rev
Log:
PR target/61060
* config/i386/i386.c (ix86_expand_set_or_movmem): If count_exp
is const0_rtx, return immediately.  Don't test count == 0 when
it is always true.

* gcc.dg/pr61060.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr61060.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.c
trunk/gcc/testsuite/ChangeLog


[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

--- Comment #8 from Jakub Jelinek jakub at gcc dot gnu.org ---
Author: jakub
Date: Tue May 13 08:31:29 2014
New Revision: 210353

URL: http://gcc.gnu.org/viewcvs?rev=210353root=gccview=rev
Log:
PR target/61060
* config/i386/i386.c (ix86_expand_set_or_movmem): If count_exp
is const0_rtx, return immediately.  Don't test count == 0 when
it is always true.

* gcc.dg/pr61060.c: New test.

Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr61060.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/config/i386/i386.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
  Known to work||4.10.0, 4.9.1
 Resolution|--- |FIXED
  Known to fail|4.10.0, 4.9.1   |4.9.0

--- Comment #9 from Jakub Jelinek jakub at gcc dot gnu.org ---
Should be fixed now for 4.9.1+.


[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-06 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

--- Comment #4 from Richard Biener rguenth at gcc dot gnu.org ---
At -O0?  Well...  it seems the expander doesn't yet see it's zero:

  /* If the LEN parameter is zero, return DEST.  */
  if (integer_zerop (len))
{
  /* Evaluate and ignore VAL in case it has side-effects.  */
  expand_expr (val, const0_rtx, VOIDmode, EXPAND_NORMAL);
  return expand_expr (dest, target, mode, EXPAND_NORMAL);

that is because len is len_5 at -O0 (no CCP), but it is TERed and thus
len_5 = 0 is expanded in-place.

I'd say the backend should better deal with this.  Or we have to
double-check (or delay) the zero-length check until after

  len_rtx = expand_normal (len);

sth like

Index: gcc/builtins.c
===
--- gcc/builtins.c  (revision 209890)
+++ gcc/builtins.c  (working copy)
@@ -3685,20 +3685,20 @@ expand_builtin_memset_args (tree dest, t
   if (expected_align  dest_align)
 expected_align = dest_align;

+  /* Stabilize the arguments in case we fail.  */
+  dest = builtin_save_expr (dest);
+  val = builtin_save_expr (val);
+  len = builtin_save_expr (len);
+
+  len_rtx = expand_normal (len);
   /* If the LEN parameter is zero, return DEST.  */
-  if (integer_zerop (len))
+  if (len_rtx == const0_rtx)
 {
   /* Evaluate and ignore VAL in case it has side-effects.  */
   expand_expr (val, const0_rtx, VOIDmode, EXPAND_NORMAL);
   return expand_expr (dest, target, mode, EXPAND_NORMAL);
 }

-  /* Stabilize the arguments in case we fail.  */
-  dest = builtin_save_expr (dest);
-  val = builtin_save_expr (val);
-  len = builtin_save_expr (len);
-
-  len_rtx = expand_normal (len);
   determine_block_size (len, len_rtx, min_size, max_size,
probable_max_size);
   dest_mem = get_memory_rtx (dest, len);


probably applies to almost all builtin expansions.

But I'd say the backend should be more fault-tolerant here.  It can't
simply reserve len == 0 for itself.


[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-06 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

--- Comment #5 from Jan Hubicka hubicka at ucw dot cz ---
 I'd say the backend should better deal with this.  Or we have to
 double-check (or delay) the zero-length check until after
 
   len_rtx = expand_normal (len);
 
 sth like

This looks good to me indeed. Thanks for explanation concerning TER.
 
 Index: gcc/builtins.c
 ===
 --- gcc/builtins.c  (revision 209890)
 +++ gcc/builtins.c  (working copy)
 @@ -3685,20 +3685,20 @@ expand_builtin_memset_args (tree dest, t
if (expected_align  dest_align)
  expected_align = dest_align;
 
 +  /* Stabilize the arguments in case we fail.  */
 +  dest = builtin_save_expr (dest);
 +  val = builtin_save_expr (val);
 +  len = builtin_save_expr (len);
 +
 +  len_rtx = expand_normal (len);
/* If the LEN parameter is zero, return DEST.  */
 -  if (integer_zerop (len))
 +  if (len_rtx == const0_rtx)
  {
/* Evaluate and ignore VAL in case it has side-effects.  */
expand_expr (val, const0_rtx, VOIDmode, EXPAND_NORMAL);
return expand_expr (dest, target, mode, EXPAND_NORMAL);
  }
 
 -  /* Stabilize the arguments in case we fail.  */
 -  dest = builtin_save_expr (dest);
 -  val = builtin_save_expr (val);
 -  len = builtin_save_expr (len);
 -
 -  len_rtx = expand_normal (len);
determine_block_size (len, len_rtx, min_size, max_size,
 probable_max_size);
dest_mem = get_memory_rtx (dest, len);
 
 
 probably applies to almost all builtin expansions.
 
 But I'd say the backend should be more fault-tolerant here.  It can't
 simply reserve len == 0 for itself.

OK, I think I can just add early return to the expander functions then (or an
assert - still it seems more like middle-end's bug as it only wastes time even
at -O0)

Honza


[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-05 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P2
  Component|rtl-optimization|target
   Target Milestone|--- |4.9.1


[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-05 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

Uroš Bizjak ubizjak at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-05-05
 Ever confirmed|0   |1

--- Comment #1 from Uroš Bizjak ubizjak at gmail dot com ---
Confirmed, modeless (const_int 0) leaks to line 24181.

(gdb) f 7
#7  0x00c4fc71 in ix86_expand_set_or_movmem (dst=0x719c5d50,
src=0x10048e0 int_mode_for_mode(machine_mode)::__FUNCTION__, src@entry=0x0,
count_exp=0x718a5470, val_exp=0x190, 
val_exp@entry=0x718a5510, align_exp=0x64,
align_exp@entry=0x718a5480, expected_align_exp=0x7ff9f00,
expected_align_exp@entry=0x718a5480, expected_size_exp=0x718a5460, 
min_size_exp=0x0, max_size_exp=0x190, max_size_exp@entry=0x718a5510,
probable_max_size_exp=0x10048e0
int_mode_for_mode(machine_mode)::__FUNCTION__,
probable_max_size_exp@entry=0x0, 
issetmem=true) at /home/uros/gcc-svn/trunk/gcc/config/i386/i386.c:24182
24182   count_exp = copy_to_mode_reg (GET_MODE (count_exp), count_exp);
(gdb) p debug_rtx (count_exp)
(const_int 0 [0])
$9 = void
(gdb) list
24177creating of promoted vector value is very cheap in this case.  */
24178 if (issetmem  alg == vector_loop  val_exp != const0_rtx)
24179   alg = unrolled_loop;
24180
24181 if (!count)
24182   count_exp = copy_to_mode_reg (GET_MODE (count_exp), count_exp);
24183 destreg = ix86_copy_addr_to_reg (XEXP (dst, 0));
24184 if (!issetmem)
24185   srcreg = ix86_copy_addr_to_reg (XEXP (src, 0));
24186

[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-05 Thread ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

Uroš Bizjak ubizjak at gmail dot com changed:

   What|Removed |Added

 CC||hubicka at ucw dot cz

--- Comment #2 from Uroš Bizjak ubizjak at gmail dot com ---
The code in ix86_expand_set_or_movmem assumes that !count implies non-const_int
count_exp:

  unsigned HOST_WIDE_INT count = 0;

...

  if (CONST_INT_P (count_exp))
min_size = max_size = probable_max_size = count = expected_size
  = INTVAL (count_exp);
...

  if (!count)
count_exp = copy_to_mode_reg (GET_MODE (count_exp), count_exp);

However, when count_exp is (const_int 0), the assumption breaks, and the code
tries to determine the mode of modeless (const_int 0) count_exp RTX.

CC author of the code.

[Bug target/61060] [4.9/4.10 Regression] ICE: in int_mode_for_mode, at stor-layout.c:400 with -free-ter

2014-05-05 Thread hubicka at ucw dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61060

--- Comment #3 from Jan Hubicka hubicka at ucw dot cz ---
 
   if (CONST_INT_P (count_exp))
 min_size = max_size = probable_max_size = count = expected_size
   = INTVAL (count_exp);
 ...
 
   if (!count)
 count_exp = copy_to_mode_reg (GET_MODE (count_exp), count_exp);
 
 However, when count_exp is (const_int 0), the assumption breaks, and the code
 tries to determine the mode of modeless (const_int 0) count_exp RTX.
 
 CC author of the code.
I would say it is job of middle-end to not expand obviously pointless
stringops...