internal compiler error: in expand_debug_locations, at cfgexpand.c:5118

Bug #1642109 reported by Colin Hercus
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-5 (Ubuntu)
Incomplete
Undecided
Unassigned

Bug Description

Hi,
I'm getting subject error when compiling attached code with options

g++ -finline-functions -m64 -O3 -c -g -MMD -MP -MF "main.o.d" -o main.o main.cpp

Using: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
System: Ubuntu 16.04

The error asked me to "Please submit a full bug report,"

This is a cut down example from a larger program. I'm compiling larger program with -m64 and have SIMD routines for SSE, AVX & AVX2

The problem goes away if I
1. Remove -O option or,
2. Remove the -g option (but I do want both of these for profiling) or,
3. Add explicit inline to
    inline __attribute__ ((target ("avx2"))) __m256i _mm256_shift_left(__m256i a, int n) and
    inline __attribute__ ((target ("avx2"))) __m256i _mm256_shift_right(__m256i a, int n)

I love gcc and was so happy when I found __attribute__ ((target ("avx2"))) option. Keep up the good work.

Thanks, Colin
PS. The routines __m256i _mm256_shift_[left|right](__m256i a, int n) are used in initialisation preceding a large loop and performance doesn't really matter. I'm sure they can be done better.

Revision history for this message
Colin Hercus (colinhercus) wrote :
description: updated
Revision history for this message
Matthias Klose (doko) wrote :

not reproducible:

$ g++ -finline-functions -m64 -O3 -c -g -MMD -MP -MF "main.o.d" -o main.o main.cpp
main.cpp: In function 'void p(AV)':
main.cpp:80:6: note: The ABI for passing parameters with 32-byte alignment has changed in GCC 4.6
 void p(union AV a) {
      ^

Changed in gcc-5 (Ubuntu):
status: New → Incomplete
Revision history for this message
In , Doko-v (doko-v) wrote :

Created attachment 40223
test case

seen on trunk, 6 and 5 branches on x86_64-linux-gnu, works with -O1 and up:

$ g++ -c -O0 main.cpp
main.cpp: In function 'void p(AV)':
main.cpp:80:6: note: The ABI for passing parameters with 32-byte alignment has changed in GCC 4.6
 void p(union AV a) {
      ^
main.cpp: In function 'void test(AV, int)':
main.cpp:101:29: internal compiler error: in convert_move, at expr.c:230
     r.av = _mm256_shift_left(a.av,n);
            ~~~~~~~~~~~~~~~~~^~~~~~~~
0x898da0 convert_move(rtx_def*, rtx_def*, int)
        ../../src/gcc/expr.c:230
0x89f5cb store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*)
        ../../src/gcc/expr.c:5628
0x89fa3e expand_assignment(tree_node*, tree_node*, bool)
        ../../src/gcc/expr.c:5320
0x7b3dcd expand_gimple_stmt_1
        ../../src/gcc/cfgexpand.c:3641
0x7b3dcd expand_gimple_stmt
        ../../src/gcc/cfgexpand.c:3737
0x7b538f expand_gimple_basic_block
        ../../src/gcc/cfgexpand.c:5744
0x7ba596 execute
        ../../src/gcc/cfgexpand.c:6358
Please submit a full bug report,
with preprocessed source if appropriate.

Revision history for this message
Matthias Klose (doko) wrote :

but reproduces with -O0

Revision history for this message
In , Marxin-m (marxin-m) wrote :
Changed in gcc:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

I think the problem is that while TYPE_MODE has the hacks for vector types (vector_type_mode call), DECL_MODE doesn't have something similar.
We have some hacks for this here and there.

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

E.g. the following untested patch fixes it (or we could do it in the callers):
--- gcc/expr.c.jj 2017-08-29 19:03:09.000000000 +0200
+++ gcc/expr.c 2017-08-30 02:09:33.150618229 +0200
@@ -7010,7 +7010,11 @@ get_inner_reference (tree exp, HOST_WIDE
       size. */
  mode = TYPE_MODE (DECL_BIT_FIELD_TYPE (field));
       else if (!DECL_BIT_FIELD (field))
- mode = DECL_MODE (field);
+ {
+ mode = DECL_MODE (field);
+ if (mode == BLKmode && VECTOR_TYPE_P (TREE_TYPE (exp)))
+ mode = TYPE_MODE (TREE_TYPE (exp));
+ }
       else if (DECL_MODE (field) == BLKmode)
  blkmode_bitfield = true;

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

GCC 5 branch is being closed

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Created attachment 42764
gcc8-pr80583.patch

Untested fix.

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Author: jakub
Date: Sat Dec 2 07:54:47 2017
New Revision: 255353

URL: https://gcc.gnu.org/viewcvs?rev=255353&root=gcc&view=rev
Log:
 PR target/78643
 PR target/80583
 * expr.c (get_inner_reference): If DECL_MODE of a non-bitfield
 is BLKmode for vector field with vector raw mode, use TYPE_MODE
 instead of DECL_MODE.

 * gcc.target/i386/pr80583.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr80583.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Fixed on the trunk so far.

Changed in gcc:
status: Confirmed → In Progress
Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Author: jakub
Date: Fri Dec 15 22:09:07 2017
New Revision: 255721

URL: https://gcc.gnu.org/viewcvs?rev=255721&root=gcc&view=rev
Log:
 Backported from mainline
 2017-12-02 Jakub Jelinek <email address hidden>

 PR target/78643
 PR target/80583
 * expr.c (get_inner_reference): If DECL_MODE of a non-bitfield
 is BLKmode for vector field with vector raw mode, use TYPE_MODE
 instead of DECL_MODE.

 * gcc.target/i386/pr80583.c: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.target/i386/pr80583.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/expr.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Fixed for 7.3+ too.

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Author: jakub
Date: Mon Jun 25 16:57:13 2018
New Revision: 262041

URL: https://gcc.gnu.org/viewcvs?rev=262041&root=gcc&view=rev
Log:
 Backported from mainline
 2017-12-02 Jakub Jelinek <email address hidden>

 PR target/78643
 PR target/80583
 * expr.c (get_inner_reference): If DECL_MODE of a non-bitfield
 is BLKmode for vector field with vector raw mode, use TYPE_MODE
 instead of DECL_MODE.

 * gcc.target/i386/pr80583.c: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/gcc.target/i386/pr80583.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/expr.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

Fixed for 6.5.

Changed in gcc:
status: In Progress → Fix Released
Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The master branch has been updated by H.J. Lu <email address hidden>:

https://gcc.gnu.org/g:1c64aba8cdf6509533f554ad86640f274cdbe37f

commit r13-3490-g1c64aba8cdf6509533f554ad86640f274cdbe37f
Author: H.J. Lu <email address hidden>
Date: Wed Oct 19 12:53:35 2022 -0700

    Always use TYPE_MODE instead of DECL_MODE for vector field

    e034c5c8957 re PR target/78643 (ICE in convert_move, at expr.c:230)

    fixed the case where DECL_MODE of a vector field is BLKmode and its
    TYPE_MODE is a vector mode because of target attribute. Remove the
    BLKmode check for the case where DECL_MODE of a vector field is a vector
    mode and its TYPE_MODE isn't a vector mode because of target attribute.

    gcc/

            PR target/107304
            * expr.cc (get_inner_reference): Always use TYPE_MODE for vector
            field with vector raw mode.

    gcc/testsuite/

            PR target/107304
            * gcc.target/i386/pr107304.c: New test.

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The releases/gcc-12 branch has been updated by H.J. Lu <email address hidden>:

https://gcc.gnu.org/g:0138ebcd482c71f55d74eb9fa533fbb54a4391d6

commit r12-8899-g0138ebcd482c71f55d74eb9fa533fbb54a4391d6
Author: H.J. Lu <email address hidden>
Date: Wed Oct 19 12:53:35 2022 -0700

    Always use TYPE_MODE instead of DECL_MODE for vector field

    e034c5c8957 re PR target/78643 (ICE in convert_move, at expr.c:230)

    fixed the case where DECL_MODE of a vector field is BLKmode and its
    TYPE_MODE is a vector mode because of target attribute. Remove the
    BLKmode check for the case where DECL_MODE of a vector field is a vector
    mode and its TYPE_MODE isn't a vector mode because of target attribute.

    gcc/

            PR target/107304
            * expr.cc (get_inner_reference): Always use TYPE_MODE for vector
            field with vector raw mode.

    gcc/testsuite/

            PR target/107304
            * gcc.target/i386/pr107304.c: New test.

    (cherry picked from commit 1c64aba8cdf6509533f554ad86640f274cdbe37f)

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The releases/gcc-11 branch has been updated by H.J. Lu <email address hidden>:

https://gcc.gnu.org/g:c97c6569c826731910459812e3608255962dab78

commit r11-10370-gc97c6569c826731910459812e3608255962dab78
Author: H.J. Lu <email address hidden>
Date: Wed Oct 19 12:53:35 2022 -0700

    Always use TYPE_MODE instead of DECL_MODE for vector field

    e034c5c8957 re PR target/78643 (ICE in convert_move, at expr.c:230)

    fixed the case where DECL_MODE of a vector field is BLKmode and its
    TYPE_MODE is a vector mode because of target attribute. Remove the
    BLKmode check for the case where DECL_MODE of a vector field is a vector
    mode and its TYPE_MODE isn't a vector mode because of target attribute.

    gcc/

            PR target/107304
            * expr.c (get_inner_reference): Always use TYPE_MODE for vector
            field with vector raw mode.

    gcc/testsuite/

            PR target/107304
            * gcc.target/i386/pr107304.c: New test.

    (cherry picked from commit 1c64aba8cdf6509533f554ad86640f274cdbe37f)

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The releases/gcc-10 branch has been updated by H.J. Lu <email address hidden>:

https://gcc.gnu.org/g:bb08940b30bd50c6e860bb8ac72d6f2ce7c1b25d

commit r10-11076-gbb08940b30bd50c6e860bb8ac72d6f2ce7c1b25d
Author: H.J. Lu <email address hidden>
Date: Wed Oct 19 12:53:35 2022 -0700

    Always use TYPE_MODE instead of DECL_MODE for vector field

    e034c5c8957 re PR target/78643 (ICE in convert_move, at expr.c:230)

    fixed the case where DECL_MODE of a vector field is BLKmode and its
    TYPE_MODE is a vector mode because of target attribute. Remove the
    BLKmode check for the case where DECL_MODE of a vector field is a vector
    mode and its TYPE_MODE isn't a vector mode because of target attribute.

    gcc/

            PR target/107304
            * expr.c (get_inner_reference): Always use TYPE_MODE for vector
            field with vector raw mode.

    gcc/testsuite/

            PR target/107304
            * gcc.target/i386/pr107304.c: New test.

    (cherry picked from commit 1c64aba8cdf6509533f554ad86640f274cdbe37f)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.