Bug 23831 - [4.1 Regression] ICE in immed_double_const with vectorized multipication
Summary: [4.1 Regression] ICE in immed_double_const with vectorized multipication
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, patch, ssemmx
Depends on:
Blocks:
 
Reported: 2005-09-12 09:17 UTC by Uroš Bizjak
Modified: 2005-09-26 19:55 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work: 4.0.0
Known to fail: 4.1.0
Last reconfirmed: 2005-09-26 08:59:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uroš Bizjak 2005-09-12 09:17:30 UTC
This testcase ICEs with -O2 -msse2 -ftree-vectorize:

void
test_1 (void)
{
  static unsigned int bm[16];
  int j;
  for (j = 0; j < 16; j++)
    bm[j] = bm[j] * 8;
}

prxxx.c: In function 'test_1':
prxxx.c:8: internal compiler error: in immed_double_const, at emit-rtl.c:468

[BTW: This bug was found when dealing with PR target/22480. As a nice 
enhancement, this code should actually be transformed into vector left shift by 
3.]
Comment 1 Andrew Pinski 2005-09-12 13:51:37 UTC
Confirmed, works correctly on powerpc-darwin with about the same IR.
Comment 2 Uroš Bizjak 2005-09-15 11:53:48 UTC
He problem is in following RTL:

(insn 30 29 31 1 (set (reg:V4SI 75)
        (mem/u/i:V4SI (symbol_ref/u:SI ("*.LC0") [flags 0x2]) [3 S16 A128])) 
541 {*movv4si_internal} (nil)
    (expr_list:REG_EQUAL (const_vector:V4SI [
                (const_int 5 [0x5])
                (const_int 5 [0x5])
                (const_int 5 [0x5])
                (const_int 5 [0x5])
            ])
        (nil)))

...

(insn 33 32 34 1 (set (subreg:TI (reg:V4SI 78) 0)
        (lshiftrt:TI (subreg:TI (reg:V4SI 75) 0)
            (const_int 32 [0x20]))) 709 {sse2_lshrti3} (nil)
    (nil))

Somehow a TImode constant is produced, and it triggers the check below:

      gcc_assert (GET_MODE_CLASS (mode) == MODE_INT
		  || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT
		  /* We can get a 0 for an error mark.  */
		  || GET_MODE_CLASS (mode) == MODE_VECTOR_INT
		  || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT);

      /* We clear out all bits that don't belong in MODE, unless they and
	 our sign bit are all one.  So we get either a reasonable negative
	 value or a reasonable unsigned value for this mode.  */
      width = GET_MODE_BITSIZE (mode);
      if (width < HOST_BITS_PER_WIDE_INT
	  && ((i0 & ((HOST_WIDE_INT) (-1) << (width - 1)))
	      != ((HOST_WIDE_INT) (-1) << (width - 1))))
	i0 &= ((HOST_WIDE_INT) 1 << width) - 1, i1 = 0;
      else if (width == HOST_BITS_PER_WIDE_INT
	       && ! (i1 == ~0 && i0 < 0))
	i1 = 0;
      else
	/* We should be able to represent this value as a constant.  */
>>>	gcc_assert (width <= 2 * HOST_BITS_PER_WIDE_INT);

HOSTS_BITS_PER_WIDE_INT is 32 bit for ia32, and TImode constants are 128 bit 
wide. I don't know the correct solution here. If the assert is commented out, 
the ICE goes away and produced code works as expected.
Comment 3 Andrew Pinski 2005-09-15 14:48:43 UTC
It might be just the time to move x86 over to HWI being 64bit like all other sanse targets, especially 
when it uses 128bit constants.
Comment 4 Andrew Pinski 2005-09-15 14:54:23 UTC
See PR 14981 for another one which was caused by the same issue before.
Comment 5 Uroš Bizjak 2005-09-26 08:59:42 UTC
This is in fact middle-end problem. Patch at http://gcc.gnu.org/ml/gcc-
patches/2005-09/msg01583.html.
Comment 6 CVS Commits 2005-09-26 18:16:25 UTC
Subject: Bug 23831

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ian@gcc.gnu.org	2005-09-26 18:16:11

Modified files:
	gcc            : ChangeLog simplify-rtx.c 

Log message:
	PR middle-end/23831
	* simplify-rtx.c (simplify_immed_subreg) [MODE_INT]: Skip
	simplification if elem_bitsize > 2 * HOST_BITS_PER_WIDE_INT.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10024&r2=2.10025
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/simplify-rtx.c.diff?cvsroot=gcc&r1=1.247&r2=1.248

Comment 7 CVS Commits 2005-09-26 18:18:18 UTC
Subject: Bug 23831

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ian@gcc.gnu.org	2005-09-26 18:17:54

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/vect: pr23831.c 

Log message:
	PR middle-end/23831
	* gcc.dg/vect/pr23831.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6103&r2=1.6104
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/vect/pr23831.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 8 Andrew Pinski 2005-09-26 19:55:30 UTC
Fixed.