Bug 85945 - [6/7 Regression] ICE in resolve_subreg_use, at lower-subreg.c:751
Summary: [6/7 Regression] ICE in resolve_subreg_use, at lower-subreg.c:751
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.1.1
: P2 normal
Target Milestone: 6.5
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-05-28 06:43 UTC by Martin Liška
Modified: 2018-06-25 18:28 UTC (History)
2 users (show)

See Also:
Host: x86_64-linux-gnu
Target: s390x-unknown-linux-gnu
Build:
Known to work:
Known to fail: 6.4.0, 7.3.0, 8.1.0, 9.0
Last reconfirmed: 2018-05-28 00:00:00


Attachments
gcc9-pr85945.patch (815 bytes, patch)
2018-05-28 16:29 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2018-05-28 06:43:35 UTC
Following causes an ICE:

$ s390x-linux-gnu-gcc -c -O1 -march=z13 ice.i
during RTL pass: subreg2
ice.i: In function ‘h’:
ice.i:16:1: internal compiler error: in resolve_subreg_use, at lower-subreg.c:751
 }
 ^
0x12512d5 resolve_subreg_use
	.././../gcc/lower-subreg.c:751
0x125262b decompose_multiword_subregs
	.././../gcc/lower-subreg.c:1602
0x125315d execute
	.././../gcc/lower-subreg.c:1741
Comment 1 Jakub Jelinek 2018-05-28 12:18:11 UTC
Where is the testcase?
Comment 2 Martin Liška 2018-05-28 12:20:47 UTC
Is missing :)

Here it is:

typedef float b;
typedef b __attribute__((vector_size(16))) c;
typedef union {
  c d;
  b a[4];
} e;
int f;
b g[4];
void h() {
  c d;
  e i;
  i.d = d;
  f = 0;
  for (; f < 4; f++)
    g[f] = i.a[f];
}
Comment 3 Jakub Jelinek 2018-05-28 14:53:13 UTC
I think the problem is that validate_subreg etc. has a restriction like:
  /* Subregs involving floating point modes are not allowed to
     change size.  Therefore (subreg:DI (reg:DF) 0) is fine, but
     (subreg:SI (reg:DF) 0) isn't.  */
but lower-subreg.c doesn't take that into account in:
         /* We only try to decompose single word subregs of multi-word
             registers.  When we find one, we return -1 to avoid iterating
             over the inner register.

             ??? This doesn't allow, e.g., DImode subregs of TImode values
             on 32-bit targets.  We would need to record the way the
             pseudo-register was used, and only decompose if all the uses
             were the same number and size of pieces.  Hopefully this
             doesn't happen much.  */

          if (outer_words == 1 && inner_words > 1)
            {
              bitmap_set_bit (decomposable_context, regno);
              iter.skip_subrtxes ();
              continue;
            }
and decompose_register creates concat with a word sized integral pseudos in it.
Comment 4 Jakub Jelinek 2018-05-28 16:29:18 UTC
Created attachment 44198 [details]
gcc9-pr85945.patch

Untested fix.
Comment 5 Jakub Jelinek 2018-06-14 13:35:38 UTC
Author: jakub
Date: Thu Jun 14 13:35:06 2018
New Revision: 261593

URL: https://gcc.gnu.org/viewcvs?rev=261593&root=gcc&view=rev
Log:
	PR target/85945
	* lower-subreg.c (find_decomposable_subregs): Don't decompose float
	subregs of multi-word pseudos unless the float mode has word size.

	* gcc.c-torture/compile/pr85945.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr85945.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lower-subreg.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2018-06-14 13:37:17 UTC
Author: jakub
Date: Thu Jun 14 13:36:43 2018
New Revision: 261594

URL: https://gcc.gnu.org/viewcvs?rev=261594&root=gcc&view=rev
Log:
	PR target/85945
	* lower-subreg.c (find_decomposable_subregs): Don't decompose float
	subregs of multi-word pseudos unless the float mode has word size.

	* gcc.c-torture/compile/pr85945.c: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/gcc.c-torture/compile/pr85945.c
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/lower-subreg.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 7 Jakub Jelinek 2018-06-15 14:02:06 UTC
Fixed for 8.2+ so far.
Comment 8 Jakub Jelinek 2018-06-22 21:29:56 UTC
Author: jakub
Date: Fri Jun 22 21:29:24 2018
New Revision: 261967

URL: https://gcc.gnu.org/viewcvs?rev=261967&root=gcc&view=rev
Log:
	Backported from mainline
	2018-06-14  Jakub Jelinek  <jakub@redhat.com>

	PR target/85945
	* lower-subreg.c (find_decomposable_subregs): Don't decompose float
	subregs of multi-word pseudos unless the float mode has word size.

	* gcc.c-torture/compile/pr85945.c: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.c-torture/compile/pr85945.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/lower-subreg.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 9 Jakub Jelinek 2018-06-25 17:53:00 UTC
Author: jakub
Date: Mon Jun 25 17:52:28 2018
New Revision: 262099

URL: https://gcc.gnu.org/viewcvs?rev=262099&root=gcc&view=rev
Log:
	Backported from mainline
	2018-06-14  Jakub Jelinek  <jakub@redhat.com>

	PR target/85945
	* lower-subreg.c (find_decomposable_subregs): Don't decompose float
	subregs of multi-word pseudos unless the float mode has word size.

	* gcc.c-torture/compile/pr85945.c: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/gcc.c-torture/compile/pr85945.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/lower-subreg.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 10 Jakub Jelinek 2018-06-25 18:28:34 UTC
Fixed for 6.5 and 7.4+ too.