https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115804
Bug ID: 115804 Summary: ICE during gimplification with new isfinite optab Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: stefansf at gcc dot gnu.org Target Milestone: --- Adding isfinitedf2 optab to the s390 backend results in ICEs already during gimplification when running the gm2 testsuite: FAIL: gm2/iso/run/pass/constructor2.mod compilation, {additional_flags= -O -g } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/constructor2.mod compilation, {additional_flags= -O } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/constructor2.mod compilation, {additional_flags= -O3 -fomit-frame-pointer -finline-functions } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/constructor2.mod compilation, {additional_flags= -O3 -fomit-frame-pointer } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/constructor2.mod compilation, {additional_flags= -Os } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/constructor2.mod compilation, {additional_flags= -g } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) UNRESOLVED: gm2/iso/run/pass/constructor2.mod execution, {additional_flags= -O -g } timeout=300 UNRESOLVED: gm2/iso/run/pass/constructor2.mod execution, {additional_flags= -O } timeout=300 UNRESOLVED: gm2/iso/run/pass/constructor2.mod execution, {additional_flags= -O3 -fomit-frame-pointer -finline-functions } timeout=300 UNRESOLVED: gm2/iso/run/pass/constructor2.mod execution, {additional_flags= -O3 -fomit-frame-pointer } timeout=300 UNRESOLVED: gm2/iso/run/pass/constructor2.mod execution, {additional_flags= -Os } timeout=300 UNRESOLVED: gm2/iso/run/pass/constructor2.mod execution, {additional_flags= -g } timeout=300 FAIL: gm2/iso/run/pass/unbounded4.mod compilation, {additional_flags= -O -g } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/unbounded4.mod compilation, {additional_flags= -O } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/unbounded4.mod compilation, {additional_flags= -O3 -fomit-frame-pointer -finline-functions } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/unbounded4.mod compilation, {additional_flags= -O3 -fomit-frame-pointer } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/unbounded4.mod compilation, {additional_flags= -Os } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/iso/run/pass/unbounded4.mod compilation, {additional_flags= -g } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) UNRESOLVED: gm2/iso/run/pass/unbounded4.mod execution, {additional_flags= -O -g } timeout=300 UNRESOLVED: gm2/iso/run/pass/unbounded4.mod execution, {additional_flags= -O } timeout=300 UNRESOLVED: gm2/iso/run/pass/unbounded4.mod execution, {additional_flags= -O3 -fomit-frame-pointer -finline-functions } timeout=300 UNRESOLVED: gm2/iso/run/pass/unbounded4.mod execution, {additional_flags= -O3 -fomit-frame-pointer } timeout=300 UNRESOLVED: gm2/iso/run/pass/unbounded4.mod execution, {additional_flags= -Os } timeout=300 UNRESOLVED: gm2/iso/run/pass/unbounded4.mod execution, {additional_flags= -g } timeout=300 FAIL: gm2/switches/check-all/run/fail/realrange.mod compilation, {additional_flags= -O -g } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/switches/check-all/run/fail/realrange.mod compilation, {additional_flags= -O } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/switches/check-all/run/fail/realrange.mod compilation, {additional_flags= -O3 -fomit-frame-pointer -finline-functions } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/switches/check-all/run/fail/realrange.mod compilation, {additional_flags= -O3 -fomit-frame-pointer } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/switches/check-all/run/fail/realrange.mod compilation, {additional_flags= -Os } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) FAIL: gm2/switches/check-all/run/fail/realrange.mod compilation, {additional_flags= -g } timeout=300 (internal compiler error: in decompose, at wide-int.h:1049) UNRESOLVED: gm2/switches/check-all/run/fail/realrange.mod execution, {additional_flags= -O -g } timeout=300 UNRESOLVED: gm2/switches/check-all/run/fail/realrange.mod execution, {additional_flags= -O } timeout=300 UNRESOLVED: gm2/switches/check-all/run/fail/realrange.mod execution, {additional_flags= -O3 -fomit-frame-pointer -finline-functions } timeout=300 UNRESOLVED: gm2/switches/check-all/run/fail/realrange.mod execution, {additional_flags= -O3 -fomit-frame-pointer } timeout=300 UNRESOLVED: gm2/switches/check-all/run/fail/realrange.mod execution, {additional_flags= -Os } timeout=300 UNRESOLVED: gm2/switches/check-all/run/fail/realrange.mod execution, {additional_flags= -g } timeout=300 While skimming over them, they all seem to be related. $ /devel/build/gcc/gm2 -B/devel/build/gcc -fm2-pathname=m2pim -I/devel/build/s390x-ibm-linux-gnu/./libgm2/libm2pim -fm2-pathname=m2log -I/devel/src/gcc/testsuite/../m2/gm2-libs-log -fm2-pathname=m2pim -I/devel/src/gcc/testsuite/../m2/gm2-libs -fm2-pathname=m2iso -I/devel/build/s390x-ibm-linux-gnu/./libgm2/libm2iso -I/devel/src/gcc/testsuite/../m2/gm2-libs-iso -fm2-pathname=- -I/devel/src/gcc/testsuite/gm2/switches/check-all/run/fail -fm2-pathname=- -fpim -L/devel/build/s390x-ibm-linux-gnu/./libgm2/libm2pim/.libs -L/devel/build/s390x-ibm-linux-gnu/./libgm2/libm2iso/.libs -fsoft-check-all -fno-m2-plugin -fno-libs=- -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers -fdiagnostics-color=never -fdiagnostics-plain-output -g -c -o /devel/build/gcc/testsuite/gm22/realrange.o /devel/src/gcc/testsuite/gm2/switches/check-all/run/fail/realrange.mod /devel/src/gcc/testsuite/gm2/switches/check-all/run/fail/realrange.mod: In function '_M2_realrange_init': /devel/src/gcc/testsuite/gm2/switches/check-all/run/fail/realrange.mod:26:11: internal compiler error: in decompose, at wide-int.h:1049 0x3c58669 internal_error(char const*, ...) /devel/src/gcc/diagnostic-global-context.cc:491 0x3c40af5 fancy_abort(char const*, int, char const*) /devel/src/gcc/diagnostic.cc:1725 0x1a5d9a7 wi::int_traits<generic_wide_int<wide_int_storage> >::decompose(long*, unsigned int, generic_wide_int<wide_int_storage> const&) /devel/src/gcc/wide-int.h:1049 0x1a5d0d3 wide_int_ref_storage<true, false>::wide_int_ref_storage<generic_wide_int<wide_int_storage> >(generic_wide_int<wide_int_storage> const&, unsigned int) /devel/src/gcc/wide-int.h:1099 0x1a5c0d3 generic_wide_int<wide_int_ref_storage<true, false> >::generic_wide_int<generic_wide_int<wide_int_storage> >(generic_wide_int<wide_int_storage> const&, unsigned int) /devel/src/gcc/wide-int.h:855 0x2665433 wi::binary_traits<generic_wide_int<wide_int_ref_storage<false, false> >, generic_wide_int<wide_int_storage>, wi::int_traits<generic_wide_int<wide_int_ref_storage<false, false> > >::precision_type, wi::int_traits<generic_wide_int<wide_int_storage> >::precision_type>::result_type wi::bit_and_not<generic_wide_int<wide_int_ref_storage<false, false> >, generic_wide_int<wide_int_storage> >(generic_wide_int<wide_int_ref_storage<false, false> > const&, generic_wide_int<wide_int_storage> const&) /devel/src/gcc/wide-int.h:2780 0x2e46075 gimple_simplify_223(gimple_match_op*, gimple**, tree_node* (*)(tree_node*), tree_node*, tree_node**, tree_code) /devel/build/gcc/gimple-match-2.cc:1894 0x30865b5 gimple_simplify_EQ_EXPR(gimple_match_op*, gimple**, tree_node* (*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*) /devel/build/gcc/gimple-match-6.cc:11542 0x31f4f43 gimple_simplify(gimple_match_op*, gimple**, tree_node* (*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*) /devel/build/gcc/gimple-match-10.cc:17727 0x3214199 gimple_resimplify2 /devel/src/gcc/gimple-match-exports.cc:1031 0x3210eab gimple_match_op::resimplify(gimple**, tree_node* (*)(tree_node*)) /devel/src/gcc/gimple-match-exports.cc:113 0x3213871 gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node* (*)(tree_node*), tree_node* (*)(tree_node*)) /devel/src/gcc/gimple-match-exports.cc:898 0x1e1d4fd fold_stmt_1 /devel/src/gcc/gimple-fold.cc:6362 0x1e1dd73 fold_stmt(gimple_stmt_iterator*) /devel/src/gcc/gimple-fold.cc:6522 0x1e7b4e7 maybe_fold_stmt /devel/src/gcc/gimplify.cc:3799 0x1e8117f gimplify_cond_expr /devel/src/gcc/gimplify.cc:4864 0x1ec7151 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /devel/src/gcc/gimplify.cc:18013 0x1e8cb97 gimplify_stmt(tree_node**, gimple**) /devel/src/gcc/gimplify.cc:7591 0x1e75637 gimplify_statement_list /devel/src/gcc/gimplify.cc:2249 0x1ec970d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) /devel/src/gcc/gimplify.cc:18504 Going down the route we have: Breakpoint 1, gimplify_cond_expr (expr_p=0x3fff7631df0, pre_p=0x3ffffff7980, fallback=0) at /devel/src/gcc/gimplify.cc:4702 (gdb) call debug (*expr_p) if (__builtin_isfinite (a / b) == 0) { m2pim_M2RTS_RealValueException ((PROC *) "/devel/src/gcc/testsuite/gm2/switches/check-all/run/fail/realrange.mod", 26, 11, (PROC *) "procedure \'_M2_realrange_init\'", (PROC *) "floating point / has caused an overflow"); } else { } Breakpoint 2, gimple_simplify_EQ_EXPR (res_op=0x3ffffff67e8, seq=0x3ffffff6bb8, valueize=0x1e1dc68 <no_follow_ssa_edges(tree_node*)>, code=..., type=0x3fff7600b28, _p0=0x3fff75fb3f0, _p1=0x3fff75f3cc0) at gimple-match-6.cc:7372 (gdb) call debug_tree (_p0) <ssa_name 0x3fff75fb3f0 type <pointer_type 0x3fff7607000 ADDRESS type <void_type 0x3fff7600f18 PROC asm_written VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x3fff7600f18 pointer_to_this <pointer_type 0x3fff7607000 ADDRESS>> sizes-gimplified public unsigned DI size <integer_cst 0x3fff75f3930 constant 64> unit-size <integer_cst 0x3fff75f3948 constant 8> align:64 warn_if_not_align:0 symtab:1023 alias-set 1 canonical-type 0x3fff7607000 pointer_to_this <pointer_type 0x3fff760d498>> def_stmt _4 = __builtin_isfinite (_3); version:4> (gdb) call debug_tree (_p1) <integer_cst 0x3fff75f3cc0 type <integer_type 0x3fff76005e8 INTEGER> constant 0> Breakpoint 3.5, wi::bit_and_not<generic_wide_int<wide_int_ref_storage<false, false> >, generic_wide_int<wide_int_storage> > (x=..., y=...) at /devel/src/gcc/wide-int.h:2777 (gdb) print x $1 = (const generic_wide_int<wide_int_ref_storage<false, false> > &) @0x3ffffff3168: {<wide_int_ref_storage<false, false>> = {<wi::storage_ref> = {val = 0x3fff75f3cd0, len = 1, precision = 32}, scratch = {31579240, 4398046462648}}, static is_sign_extended = false} (gdb) print y $2 = (const generic_wide_int<wide_int_storage> &) @0x3ffffff3188: {<wide_int_storage> = {u = {val = {-1, 4397901757632, 4398046458176, 64, 65109328}, valp = 0xffffffffffffffff}, len = 1, precision = 64}, static needs_write_val_arg = false} x and y have different precision which is why we fail in wi::bit_and_not at WIDE_INT_REF_FOR (T2) yi (y, precision); x and y are coming from bool gimple_simplify_223 (gimple_match_op *res_op, gimple_seq *seq, tree (*valueize)(tree) ATTRIBUTE_UNUSED, const tree ARG_UNUSED (type), tree *ARG_UNUSED (captures), const enum tree_code ARG_UNUSED (cmp)) { const bool debug_dump = dump_file && (dump_flags & TDF_FOLDING); if (wi::bit_and_not (wi::to_wide (captures[1]), get_nonzero_bits (captures[0])) != 0 with (gdb) call debug_tree(captures[1]) <integer_cst 0x3fff75f3cc0 type <integer_type 0x3fff76005e8 INTEGER> constant 0> (gdb) call debug_tree(captures[0]) <ssa_name 0x3fff75fb3f0 type <pointer_type 0x3fff7607000 ADDRESS type <void_type 0x3fff7600f18 PROC asm_written VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x3fff7600f18 pointer_to_this <pointer_type 0x3fff7607000 ADDRESS>> sizes-gimplified public unsigned DI size <integer_cst 0x3fff75f3930 constant 64> unit-size <integer_cst 0x3fff75f3948 constant 8> align:64 warn_if_not_align:0 symtab:1023 alias-set 1 canonical-type 0x3fff7607000 pointer_to_this <pointer_type 0x3fff760d498>> def_stmt _4 = __builtin_isfinite (_3); version:4> get_nonzero_bits returns with return wi::shwi (-1, precision); resulting in a wide-int with 64-bit precision whereas wi::to_wide (captures[1]) results in a wide-int with 32-bit precision.