Bug 103033 - [12 regression] c-c++-common/auto-init-4.c ICEs starting with r12-4829
Summary: [12 regression] c-c++-common/auto-init-4.c ICEs starting with r12-4829
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: 12.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2021-11-01 21:53 UTC by seurer
Modified: 2021-11-03 10:13 UTC (History)
2 users (show)

See Also:
Host: powerpc64-linux-gnu, powerpc64le-linux-gnu
Target: powerpc64-linux-gnu, powerpc64le-linux-gnu
Build: powerpc64-linux-gnu, powerpc64le-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2021-11-02 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description seurer 2021-11-01 21:53:08 UTC
g:429e3b7d8bf6609ddf7c7b1e49244997e9ac76b8, r12-4829

make  -k check-gcc RUNTESTFLAGS="dg.exp=c-c++-common/auto-init-4.c"
FAIL: c-c++-common/auto-init-4.c  -Wc++-compat  (internal compiler error)
FAIL: c-c++-common/auto-init-4.c  -Wc++-compat  (test for excess errors)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++98 (internal compiler error)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++98 (test for excess errors)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++14 (internal compiler error)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++14 (test for excess errors)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++17 (internal compiler error)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++17 (test for excess errors)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++2a (internal compiler error)
FAIL: c-c++-common/auto-init-4.c  -std=gnu++2a (test for excess errors)


spawn -ignore SIGHUP /home/seurer/gcc/git/build/gcc-test/gcc/xgcc -B/home/seurer/gcc/git/build/gcc-test/gcc/ /home/seurer/gcc/git/gcc-test/gcc/testsuite/c-c++-common/auto-init-4.c -fdiagnostics-plain-output -Wc++-compat -ftrivial-auto-var-init=pattern -fdump-tree-gimple -S -o auto-init-4.s
during RTL pass: expand
/home/seurer/gcc/git/gcc-test/gcc/testsuite/c-c++-common/auto-init-4.c: In function 'foo':
/home/seurer/gcc/git/gcc-test/gcc/testsuite/c-c++-common/auto-init-4.c:11:15: internal compiler error: Segmentation fault
0x10bd8533 crash_signal
	/home/seurer/gcc/git/gcc-test/gcc/toplev.c:322
0x10687390 location_wrapper_p(tree_node const*)
	/home/seurer/gcc/git/gcc-test/gcc/tree.h:4136
0x10687390 tree_strip_any_location_wrapper(tree_node*)
	/home/seurer/gcc/git/gcc-test/gcc/tree.h:4148
0x10687390 operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int)
	/home/seurer/gcc/git/gcc-test/gcc/fold-const.c:2969
0x10682e33 operand_compare::verify_hash_value(tree_node const*, tree_node const*, unsigned int, bool*)
	/home/seurer/gcc/git/gcc-test/gcc/fold-const.c:3956
0x106875ff operand_compare::verify_hash_value(tree_node const*, tree_node const*, unsigned int, bool*)
	/home/seurer/gcc/git/gcc-test/gcc/tree.h:4149
0x106875ff operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int)
	/home/seurer/gcc/git/gcc-test/gcc/fold-const.c:2965
0x106638cf expand_assignment(tree_node*, tree_node*, bool)
	/home/seurer/gcc/git/gcc-test/gcc/expr.c:5366
0x10809b4f expand_DEFERRED_INIT
	/home/seurer/gcc/git/gcc-test/gcc/internal-fn.c:3101
0x10810c4b expand_internal_call(internal_fn, gcall*)
	/home/seurer/gcc/git/gcc-test/gcc/internal-fn.c:4220
0x10810c4b expand_internal_call(gcall*)
	/home/seurer/gcc/git/gcc-test/gcc/internal-fn.c:4228
0x1048c2a7 expand_call_stmt
	/home/seurer/gcc/git/gcc-test/gcc/cfgexpand.c:2749
0x1048c2a7 expand_gimple_stmt_1
	/home/seurer/gcc/git/gcc-test/gcc/cfgexpand.c:3876
0x1048c2a7 expand_gimple_stmt
	/home/seurer/gcc/git/gcc-test/gcc/cfgexpand.c:4040
0x10494dab expand_gimple_basic_block
	/home/seurer/gcc/git/gcc-test/gcc/cfgexpand.c:6085
0x10497d47 execute
	/home/seurer/gcc/git/gcc-test/gcc/cfgexpand.c:6811
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
compiler exited with status 1


commit 429e3b7d8bf6609ddf7c7b1e49244997e9ac76b8 (HEAD, refs/bisect/bad)
Author: Oracle Public Cloud User <opc@qinzhao-aarch64-ol8.allregionaliads.osdevelopmeniad.oraclevcn.com>
Date:   Mon Nov 1 15:14:26 2021 +0000

    PR 102281 (-ftrivial-auto-var-init=zero causes ice)
Comment 1 Richard Biener 2021-11-02 08:40:22 UTC
I can't reproduce this with a cross from x86_64-linux to powerpc64le-linux.
Comment 2 qinzhao 2021-11-02 18:06:14 UTC
I can repeat this ICE on the gcc farm machine gcc112, which is a Powerpcle linux machine with the latest upstream gcc (11/2/2021).


and locate the issue at:
Breakpoint 2, expand_DEFERRED_INIT (stmt=0x3fffaf162c88) at ../../latest_gcc_git/gcc/internal-fn.c:3085
3085		  if (can_native_interpret_type_p (var_type))
(gdb) n
3086		    init = native_interpret_expr (var_type, buf, total_bytes);
(gdb) n
3105	      expand_assignment (lhs, init, false);
(gdb) print init
$8 = (tree) 0x0
(gdb) call debug_tree(var_type)
 <real_type 0x3fffaf0c1500 long double sizes-gimplified TF
    size <integer_cst 0x3fffaf091038 type <integer_type 0x3fffaf0c01f8 bitsizetype> constant 128>
    unit-size <integer_cst 0x3fffaf091050 type <integer_type 0x3fffaf0c0150 sizetype> constant 16>
    align:128 warn_if_not_align:0 symtab:0 alias-set 1 canonical-type 0x3fffaf0c1500 precision:127
    pointer_to_this <pointer_type 0x3fffaf0c1a40>>

i.e, in the above, there is an inconsistency between "can_native_interpret_type_p" and "native_interpret_expr" for "long double" on Powerpcle: although "can_native_interpre_type_p(long double)" return true, "native_interpret_expr (long double, buf,...) return NULL on Powerpcle, This is due to the following code in "native_interpret_expr":

  if (MODE_COMPOSITE_P (mode))
    {
      /* For floating point values in composite modes, punt if this folding
         doesn't preserve bit representation.  As the mode doesn't have fixed
         precision while GCC pretends it does, there could be valid values that
         GCC can't really represent accurately.  See PR95450.  */
      unsigned char buf[24];
      if (native_encode_expr (ret, buf, total_bytes, 0) != total_bytes
          || memcmp (ptr, buf, total_bytes) != 0)
        ret = NULL_TREE;
    }

this part of the code is to fix PR95450, which is bug on Powerpcle too, so, looks like this is the reason why this bug only for powerpc.
Comment 3 Richard Biener 2021-11-02 18:24:46 UTC
OK, that's good enough explanation for a fix.
Comment 4 GCC Commits 2021-11-03 10:13:06 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

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

commit r12-4859-gc081d0a3b0291297f04a05c833d2ffa8de3a7a1a
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Nov 3 11:10:19 2021 +0100

    middle-end/103033 - drop native_interpret_expr with .DEFERRED_INIT expansion
    
    This drops the use of native_interpret_expr which can fail even though
    can_native_interpret_expr_p returns true in favor of simply folding
    the VIEW_CONVERT_EXPR punning.
    
    2021-11-03  Richard Biener  <rguenther@suse.de>
    
            PR middle-end/103033
            * internal-fn.c (expand_DEFERRED_INIT): Elide the
            native_interpret_expr path in favor of folding the
            VIEW_CONVERT_EXPR generated when punning the RHS.
Comment 5 Richard Biener 2021-11-03 10:13:16 UTC
Fixed.