Bug 109711 - [14 regression] ICE (tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in verify_range, at value-range.cc:1060) when building ffmpeg-4.4.4 since r14-377-gc92b8be9b52b7e
Summary: [14 regression] ICE (tree check: expected class ‘type’, have ‘exceptional’ (e...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 14.0
: P1 normal
Target Milestone: 14.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-checking
: 109696 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-05-03 11:42 UTC by Sam James
Modified: 2023-11-05 21:41 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-05-03 00:00:00


Attachments
qcelpdec.i (59.39 KB, text/plain)
2023-05-03 11:42 UTC, Sam James
Details
untested (510 bytes, patch)
2023-05-03 13:52 UTC, Aldy Hernandez
Details | Diff
patch in testing (1.11 KB, patch)
2023-05-03 15:32 UTC, Aldy Hernandez
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2023-05-03 11:42:09 UTC
Created attachment 54977 [details]
qcelpdec.i

Hit this when building ffmpeg-4.4.4 w/ gcc 14. Needs checking. GCC 13 is ok.

```
aarch64-unknown-linux-gnu-gcc -I. -Isrc/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -
DBUILDING_avcodec -O3   -std=c11 -fPIC -pthread   -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/fribidi  -I/usr/i
nclude/freetype2 -I/usr/include/librsvg-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include
/gdk-pixbuf-2.0 -I/usr/include/libpng16 -pthread -I/usr/include/cairo -I/usr/include/freetype2 -I/usr/include/pixman-1   -DX264_API_IMPORTS      -Wdeclaration-after-statement -Wall -Wdi
sabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parenthes
es -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -Wno-bool-operation -Wno-char-subscripts -O3 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -W
error=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -Wno-maybe-uninitialized -I/usr/include/SDL2 -D_REENTRANT
   -MMD -MF libavcodec/qcelpdec.d -MT libavcodec/qcelpdec.o -c -o libavcodec/qcelpdec.o src/libavcodec/qcelpdec.c
during IPA pass: inline
src/libavcodec/qcelpdec.c:802:1: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in verify_range, at value-range.cc:1060
  802 | };
      | ^
0x6b8ed7 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree.cc:8949
0x120adbf tree_class_check(tree_node*, tree_code_class, char const*, int, char const*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree.h:3663
0x120adbf irange::verify_range()
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/value-range.cc:1060
0x120af4f irange::operator=(irange const&)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/value-range.cc:923
0xb82707 int_range<2u>::operator=(int_range<2u> const&)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/value-range.h:817
0xb82707 evaluate_conditions_for_known_args
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-fnsummary.cc:517
0xb9ab7f do_estimate_edge_size(cgraph_edge*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline-analysis.cc:335
0xb9d883 estimate_edge_size(cgraph_edge*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline.h:79
0xb9d883 estimate_edge_growth(cgraph_edge*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline.h:100
0xb9c04f do_estimate_growth_1
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline-analysis.cc:434
0xb9c193 cgraph_node::call_for_symbol_and_aliases(bool (*)(cgraph_node*, void*), void*, bool)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/cgraph.h:3412
0xb9c193 estimate_growth(cgraph_node*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline-analysis.cc:472
0x1e82d27 inline_small_functions
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline.cc:2042
0x1e82d27 ipa_inline
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline.cc:2811
0x1e82d27 execute
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/ipa-inline.cc:3210
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
```

----
```
$ aarch64-unknown-linux-gnu-gcc -c qcelpdec.i -O2
during IPA pass: inline
src/libavcodec/qcelpdec.c:802:1: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in verify_range, at value-range.cc:1060
0x6b8ed7 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree.cc:8949
0x120adbf tree_class_check(tree_node*, tree_code_class, char const*, int, char const*)
        /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/tree.h:3663
0x120adbf irange::verify_range()
[...]

$ gcc (Gentoo 14.0.0.9999 p, commit 490c1c096ca1d3a1f4a84801a46231d64c07ba49) 14.0.0 20230503 (experimental) 6313b0457394172b13978b9772d49eea1d68d3a1
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
Comment 1 Martin Liška 2023-05-03 11:58:03 UTC
I reduced that to:

$ cat pr109711.i
void lspf2lpc();

int interpolate_lpc_q_0;

void
interpolate_lpc(int subframe_num) {
  float weight;
  if (interpolate_lpc_q_0)
    weight = subframe_num;
  else
    weight = 1.0;
  if (weight != 1.0)
    lspf2lpc();
}

void
qcelp_decode_frame() {
  int i;
  for (;; i++)
    interpolate_lpc(i);
}

$ /dev/shm/objdir2/gcc/xgcc -B/dev/shm/objdir2/gcc pr109711.i -c -O2
during IPA pass: inline
pr109711.i:21:1: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in verify_range, at value-range.cc:1060
   21 | }
      | ^
0x84dfd7 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*)
	/home/marxin/Programming/gcc/gcc/tree.cc:8949
0x85baff tree_class_check(tree_node*, tree_code_class, char const*, int, char const*)
	/home/marxin/Programming/gcc/gcc/tree.h:3663
0x85baff irange::verify_range()
	/home/marxin/Programming/gcc/gcc/value-range.cc:1060
0x1279d97 irange::operator=(irange const&)
	/home/marxin/Programming/gcc/gcc/value-range.cc:923
0xcd61a7 int_range<2u>::operator=(int_range<2u> const&)
	/home/marxin/Programming/gcc/gcc/value-range.h:817
0xcd61a7 evaluate_conditions_for_known_args
	/home/marxin/Programming/gcc/gcc/ipa-fnsummary.cc:517
0xcee9c5 do_estimate_edge_size(cgraph_edge*)
	/home/marxin/Programming/gcc/gcc/ipa-inline-analysis.cc:335
0xcf1465 estimate_edge_size(cgraph_edge*)
	/home/marxin/Programming/gcc/gcc/ipa-inline.h:79
0xcf1465 estimate_edge_growth(cgraph_edge*)
	/home/marxin/Programming/gcc/gcc/ipa-inline.h:100
0xcefe15 do_estimate_growth_1
	/home/marxin/Programming/gcc/gcc/ipa-inline-analysis.cc:434
0xcefef6 cgraph_node::call_for_symbol_and_aliases(bool (*)(cgraph_node*, void*), void*, bool)
	/home/marxin/Programming/gcc/gcc/cgraph.h:3412
0xcefef6 estimate_growth(cgraph_node*)
	/home/marxin/Programming/gcc/gcc/ipa-inline-analysis.cc:472
0x1d972c4 inline_small_functions
	/home/marxin/Programming/gcc/gcc/ipa-inline.cc:2042
0x1d972c4 ipa_inline
	/home/marxin/Programming/gcc/gcc/ipa-inline.cc:2811
0x1d972c4 execute
	/home/marxin/Programming/gcc/gcc/ipa-inline.cc:3210
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 2 Martin Liška 2023-05-03 12:05:37 UTC
Started with r14-377-gc92b8be9b52b7e and it's not related to aarch64, can reproduce on x86_64-linux-gnu as well.
Comment 3 Martin Liška 2023-05-03 12:07:44 UTC
Hm, on x86_64-linux-gnu, it started with r13-6616-g2246d576f922ba.
Comment 4 Sam James 2023-05-03 12:10:34 UTC
Slightly smaller:

```
void lspf2lpc();

void interpolate_lpc(int subframe_num) {
  float weight = 0.25 * subframe_num + 1;
  if (weight)
    lspf2lpc();
}

void qcelp_decode_frame() {
  int i;
  for (;; i++)
    interpolate_lpc(i);
}
```
Comment 5 Tamar Christina 2023-05-03 13:14:26 UTC
(In reply to Martin Liška from comment #3)
> Hm, on x86_64-linux-gnu, it started with r13-6616-g2246d576f922ba.

$ cat prtest2.c
void lspf2lpc();

int interpolate_lpc_q_0;

void
interpolate_lpc(int subframe_num) {
  float weight;
  if (interpolate_lpc_q_0)
    weight = subframe_num;
  else
    weight = 1.0;
  if (weight != 1.0)
    lspf2lpc();
}

void
qcelp_decode_frame() {
  int i;
  for (;; i++)
    interpolate_lpc(i);
}

$ ./install/bin/gcc --version
gcc (GCC) 13.0.1 20230312 (experimental)

$ git log -1
commit 2246d576f922bae3629da0fe1dbfcc6ff06769ad (HEAD)
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Sun Mar 12 18:39:33 2023 +0000

    middle-end: Revert can_special_div_by_const changes [PR108583]

    This reverts the changes for the CAN_SPECIAL_DIV_BY_CONST hook.

    gcc/ChangeLog:

            PR target/108583
            * doc/tm.texi (TARGET_VECTORIZE_CAN_SPECIAL_DIV_BY_CONST): Remove.
            * doc/tm.texi.in: Likewise.
            * explow.cc (round_push, align_dynamic_address): Revert previous patch.
            * expmed.cc (expand_divmod): Likewise.
            * expmed.h (expand_divmod): Likewise.
            * expr.cc (force_operand, expand_expr_divmod): Likewise.
            * optabs.cc (expand_doubleword_mod, expand_doubleword_divmod): Likewise.
            * target.def (can_special_div_by_const): Remove.
            * target.h: Remove tree-core.h include
            * targhooks.cc (default_can_special_div_by_const): Remove.
            * targhooks.h (default_can_special_div_by_const): Remove.
            * tree-vect-generic.cc (expand_vector_operation): Remove hook.
            * tree-vect-patterns.cc (vect_recog_divmod_pattern): Remove hook.
            * tree-vect-stmts.cc (vectorizable_operation): Remove hook.

$ ./install/bin/gcc -O2 -S -o - prtest2.c
        .file   "prtest2.c"
        .text
        .p2align 4
        .globl  interpolate_lpc
        .type   interpolate_lpc, @function
interpolate_lpc:
.LFB0:
        .cfi_startproc
        movl    interpolate_lpc_q_0(%rip), %eax
        testl   %eax, %eax
        je      .L1
        pxor    %xmm0, %xmm0
        cvtsi2ssl       %edi, %xmm0
        ucomiss .LC0(%rip), %xmm0
        jp      .L4
        jne     .L4
.L1:
        ret
        .p2align 4,,10
        .p2align 3
...

Also that commit doesn't build because I forgot to cp tm.texi to the source directory after the revert.

So I think the bisect probably didn't find it in that range.

https://godbolt.org/z/r44xGzarY indicates GCC 13.1 is fine.  So I don't think this one is mine.
Comment 6 Tamar Christina 2023-05-03 13:47:31 UTC
my own bisect does indeed end up at r14-377-gc92b8be9b52b7e and cannot reproduce it on GCC 13.
Comment 7 Aldy Hernandez 2023-05-03 13:52:17 UTC
It looks like IPA is trying to set a range for a float even though value_range does not support floats.  This worked before because legacy silently set a range of error_mark_node.
Comment 8 Aldy Hernandez 2023-05-03 13:52:54 UTC
Created attachment 54980 [details]
untested

This may fix it.
Comment 9 Aldy Hernandez 2023-05-03 15:32:30 UTC
Created attachment 54982 [details]
patch in testing

I think it's easiest to restore the legacy behavior for now.  A proper conversion of IPA should follow.
Comment 10 GCC Commits 2023-05-03 17:15:58 UTC
The master branch has been updated by Aldy Hernandez <aldyh@gcc.gnu.org>:

https://gcc.gnu.org/g:2b8a27634f5d28e3e7c4a08bf065f2daada7aed2

commit r14-458-g2b8a27634f5d28e3e7c4a08bf065f2daada7aed2
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed May 3 17:29:24 2023 +0200

    Allow varying ranges of unknown types in irange::verify_range [PR109711]
    
    The old legacy code allowed building ranges of unknown types so passes
    like IPA could build and propagate VARYING.  For now it's easiest to
    allow the old behavior, it's not like you can do anything with these
    ranges except build them and copy them.
    
    Eventually we should convert all users of set_varying() to use
    supported types.  I will address this in my upcoming IPA work.
    
            PR tree-optimization/109711
    
    gcc/ChangeLog:
    
            * value-range.cc (irange::verify_range): Allow types of
            error_mark_node.
Comment 11 Aldy Hernandez 2023-05-03 17:16:59 UTC
fixed
Comment 12 Andrew Pinski 2023-11-05 21:41:35 UTC
*** Bug 109696 has been marked as a duplicate of this bug. ***