Bug 27158 - [4.1/4.2 regression] ICE in extract_insn with -maltivec
Summary: [4.1/4.2 regression] ICE in extract_insn with -maltivec
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.0
: P1 normal
Target Milestone: 4.1.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, ra
Depends on:
Blocks:
 
Reported: 2006-04-14 10:01 UTC by Martin Michlmayr
Modified: 2006-05-11 16:19 UTC (History)
4 users (show)

See Also:
Host: powerpc-linux-gnu
Target: powerpc-linux-gnu
Build: powerpc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-04-17 00:43:58


Attachments
test case for 4.1 (834 bytes, patch)
2006-04-14 10:04 UTC, Martin Michlmayr
Details | Diff
test case for 4.2 (753 bytes, patch)
2006-04-14 10:31 UTC, Martin Michlmayr
Details | Diff
preprocessed source (18.00 KB, patch)
2006-04-14 10:33 UTC, Martin Michlmayr
Details | Diff
preprocessed source (18.00 KB, application/octet-stream)
2006-04-14 10:33 UTC, Martin Michlmayr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2006-04-14 10:01:55 UTC
I get an ICE in extract_insn with -maltivec.  The original source file works with gcc 4.0 but fails with 4.1 and 4.2.  This reduced test case fails with 4.1 but works with 4.2.  I'll run it through delta again to find a test case for 4.2.

304:tbm@test: ~/delta/bin] gcc-4.1 -maltivec -O1 -c mini.c
305:tbm@test: ~/delta/bin] gcc-4.1 -maltivec -O2 -c mini.c
mini.c: In function ‘nb_kernel112_ppc_altivec’:
mini.c:110: error: unrecognizable insn:
(insn 287 43 227 3 (set (reg:V4SF 90 13)
        (mem/u/c/i:V4SF (symbol_ref/u:SI ("*.LC0") [flags 0x2]) [3 S16 A128])) -1 (nil)
    (nil))
mini.c:110: internal compiler error: in extract_insn, at recog.c:2084
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.
Preprocessed source stored into /tmp/cc6nkhMT.out file, please attach this to your bugreport.
zsh: exit 1     gcc-4.1 -maltivec -O2 -c mini.c
306:tbm@test: ~/delta/bin] /usr/lib/gcc-snapshot/bin/gcc -maltivec -O2 -c mini.c
307:tbm@test: ~/delta/bin]

This may be related to PR19960 but doesn't appear to be the same.
Comment 1 Martin Michlmayr 2006-04-14 10:04:04 UTC
Created attachment 11266 [details]
test case for 4.1

shows the ICE in gcc 4.1
Comment 2 Martin Michlmayr 2006-04-14 10:31:14 UTC
Created attachment 11267 [details]
test case for 4.2
Comment 3 Martin Michlmayr 2006-04-14 10:33:09 UTC
Created attachment 11268 [details]
preprocessed source

Unfortunately, I don't get delta to generate a test case that shows the bug both in 4.1 and 4.2.  The preprocessed file shows the ICE on 4.1 and 4.2 though.
Comment 4 Martin Michlmayr 2006-04-14 10:33:18 UTC
Created attachment 11269 [details]
preprocessed source

Unfortunately, I don't get delta to generate a test case that shows the bug both in 4.1 and 4.2.  The preprocessed file shows the ICE on 4.1 and 4.2 though.
Comment 5 Andrew Pinski 2006-04-14 16:57:49 UTC
Usually what is happening is that reload is doing the constant loading for some reason.
Comment 6 Andrew Pinski 2006-04-14 17:34:27 UTC
Thanks for the testcases.
Comment 7 Andrew Pinski 2006-04-17 00:43:58 UTC
Confirmed.
Comment 8 Paolo Bonzini 2006-04-18 13:47:50 UTC
Seems similar to PR24230, but cannot be fixed really in the same way.
Comment 9 Paolo Bonzini 2006-04-18 14:29:56 UTC
The mem is for a

(const_vector:V4SF [
        (const_double:SF -NaN [-NaN])
        (const_double:SF -NaN [-NaN])
        (const_double:SF -NaN [-NaN])
        (const_double:SF -NaN [-NaN])
    ])
Comment 10 Paolo Bonzini 2006-04-18 14:39:42 UTC
It's probably two different bugs, since the 4.1 bug is in loop.c.  We need to add a can_assign_to_reg_p call before creating a movable.
Comment 11 Paolo Bonzini 2006-04-18 15:20:20 UTC
... but then anyway the bug pops up in reload.  So it is definitely the same bug as PR24230, and here is a modified version of the PR24230 testcase:

/* Compile with -O2 -maltivec */
#define REGLIST                                                              \
         "77",  "78",  "79",  "80",  "81",  "82",  "83",  "84",  "85",  "86",\
         "87",  "88",  "89",  "90",  "91",  "92",  "93",  "94",  "95",  "96",\
         "97",  "98",  "99", "100", "101", "102", "103", "104", "105", "106",\
        "107", "108"

typedef __attribute__ ((vector_size (16))) float v4sf;

void
foo (int H)
{
  volatile v4sf tmp;
  while (H-- > 0)
    {
      asm ("" : : : REGLIST);
      tmp = (v4sf) __builtin_altivec_vspltisw (1);
    }
}

fails on 4.1, didn't test on 4.2.
Comment 12 Martin Michlmayr 2006-04-18 15:26:46 UTC
also fails on 4.2.
Comment 13 Andrew Pinski 2006-05-01 05:45:58 UTC
The problem here is that we don't recongize the constant is resepentable with vspltisw.
Hmm.
Comment 14 Andrew Pinski 2006-05-01 05:50:13 UTC
Hmm, maybe really this is just the RA playing tricks in that it should be able to move
(insn 22 16 48 3 (set (reg:V4SI 126)
        (vec_duplicate:V4SI (const_int 1 [0x1]))) 755 {altivec_vspltisw} (nil)
    (expr_list:REG_EQUIV (const_vector:V4SI [
                (const_int 1 [0x1])
                (const_int 1 [0x1])
                (const_int 1 [0x1])
                (const_int 1 [0x1])
            ])
        (nil)))

Back into the loop after the asm.
Comment 15 Roger Sayle 2006-05-08 21:10:00 UTC
Subject: Bug 27158

Author: sayle
Date: Mon May  8 21:09:49 2006
New Revision: 113632

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113632
Log:

	PR target/27158
	* reload.c (find_reloads_toplev): Only return the simplified SUBREG
	of a reg_equiv_constant if the result is a legitimate constant.

	* gcc.target/powerpc/pr27158.c: New test case.


Added:
    trunk/gcc/testsuite/gcc.target/powerpc/pr27158.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload.c
    trunk/gcc/testsuite/ChangeLog

Comment 16 Roger Sayle 2006-05-11 14:17:27 UTC
Subject: Bug 27158

Author: sayle
Date: Thu May 11 14:17:19 2006
New Revision: 113695

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113695
Log:

	PR target/27158
	* reload.c (find_reloads_toplev): Only return the simplified SUBREG
	of a reg_equiv_constant if the result is a legitimate constant.

	* gcc.target/powerpc/pr27158.c: New test case.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.target/powerpc/pr27158.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/reload.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 17 Andrew Pinski 2006-05-11 16:19:40 UTC
Fixed.
Comment 18 Roger Sayle 2006-06-12 02:03:03 UTC
Subject: Bug 27158

Author: sayle
Date: Mon Jun 12 02:02:14 2006
New Revision: 114558

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114558
Log:

	PR target/27158
	* config/rs6000/rs6000.c (const_vector_elt_as_int): New function to
	extract a CONST_VECTOR element and interpret it as an integer.
	(vspltis_constant): Use const_vector_elt_as_int instead of the
	macro CONST_VECTOR_ELT in order to handle FP vector modes.
	* config/rs6000/predicates.md (easy_vector_const): Consider
	floating point ALTIVEC_VECTOR_MODEs via easy_altivec_constant.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/predicates.md
    trunk/gcc/config/rs6000/rs6000.c

Comment 19 Roger Sayle 2006-06-12 02:10:48 UTC
Subject: Bug 27158

Author: sayle
Date: Mon Jun 12 02:10:24 2006
New Revision: 114559

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114559
Log:

	PR target/27858
	Revert incorrect fix for PR target/27158
	2006-05-08  Roger Sayle  <roger@eyesopen.com>
	* reload.c (find_reloads_toplev): Only return the simplified SUBREG
	of a reg_equiv_constant if the result is a legitimate constant.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload.c

Comment 20 Roger Sayle 2006-06-14 14:43:57 UTC
Subject: Bug 27158

Author: sayle
Date: Wed Jun 14 14:43:49 2006
New Revision: 114641

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114641
Log:

	PR target/27158
	* config/rs6000/rs6000.c (const_vector_elt_as_int): New function to
	extract a CONST_VECTOR element and interpret it as an integer.
	(vspltis_constant): Use const_vector_elt_as_int instead of the
	macro CONST_VECTOR_ELT in order to handle FP vector modes.
	* config/rs6000/predicates.md (easy_vector_const): Consider
	floating point ALTIVEC_VECTOR_MODEs via easy_altivec_constant.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/rs6000/predicates.md
    branches/gcc-4_1-branch/gcc/config/rs6000/rs6000.c

Comment 21 Roger Sayle 2006-06-14 14:46:46 UTC
Subject: Bug 27158

Author: sayle
Date: Wed Jun 14 14:46:33 2006
New Revision: 114642

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114642
Log:

	PR target/27858
	Revert incorrect fix for PR target/27158
	2006-05-11  Roger Sayle  <roger@eyesopen.com>
	* reload.c (find_reloads_toplev): Only return the simplified SUBREG
	of a reg_equiv_constant if the result is a legitimate constant.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/reload.c