$ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /tmp/tmp.oJWiD4wb77-gcc-builder/gcc/configure --enable-languages=c,c++,lto --enable-checking-yes --enable-multiarch --prefix=/scratch/software/gcc-trunk --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20210621 (experimental) [master revision :ac955e7ab:3e42ff715697c75c4fb4aed550a8a15edb3eeea6] (GCC) $ cat mutant.c struct S { int i; } baz(struct S *p) { setjmp(p--); } $ gcc-trunk mutant.c mutant.c: In function ‘baz’: mutant.c:4:3: warning: implicit declaration of function ‘setjmp’ [-Wimplicit-function-declaration] 4 | setjmp(p--); | ^~~~~~ mutant.c:3:3: error: type mismatch in ‘pointer_plus_expr’ 3 | } baz(struct S *p) { | ^~~ struct S * <<< error >>> sizetype p = _1 + 18446744073709551612; mutant.c:3:3: internal compiler error: ‘verify_gimple’ failed 0xf4c4c5 verify_gimple_in_seq(gimple*) /tmp/tmp.oJWiD4wb77-gcc-builder/gcc/gcc/tree-cfg.c:5183 0xc3a336 gimplify_body(tree_node*, bool) /tmp/tmp.oJWiD4wb77-gcc-builder/gcc/gcc/gimplify.c:15422 0xc3a4d1 gimplify_function_tree(tree_node*) /tmp/tmp.oJWiD4wb77-gcc-builder/gcc/gcc/gimplify.c:15493 0xa8be17 cgraph_node::analyze() /tmp/tmp.oJWiD4wb77-gcc-builder/gcc/gcc/cgraphunit.c:670 0xa8ed11 analyze_functions /tmp/tmp.oJWiD4wb77-gcc-builder/gcc/gcc/cgraphunit.c:1234 0xa8f7e1 symbol_table::finalize_compilation_unit() /tmp/tmp.oJWiD4wb77-gcc-builder/gcc/gcc/cgraphunit.c:2508 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.
Started with r7-536-g381cdae49785fc4b.
I will have a look.
OK, so the issue is we're calling gimplify_expr (...., false /*allow_ssa*/) on 'p--' and the gimplified sequence looks like the following on the pre_p sequence: p.0_1 = p; p = p.0_1 + 18446744073709551612; and the gimplify_expr result is just p.0_1. Then we do /* Avoid the extra copy if possible. */ *expr_p = create_tmp_reg (TREE_TYPE (name)); if (!gimple_nop_p (SSA_NAME_DEF_STMT (name))) gimple_set_lhs (SSA_NAME_DEF_STMT (name), *expr_p); release_ssa_name (name); but obviously that disregards that there's other uses of p.0_1 already. I suppose the above might be premature optimization but I'm going to gather some statistics on that I guess.
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:b4e21c80462682c4e6e5e487fe87107b27f8b4bd commit r12-1729-gb4e21c80462682c4e6e5e487fe87107b27f8b4bd Author: Richard Biener <rguenther@suse.de> Date: Tue Jun 22 12:13:44 2021 +0200 middle-end/101156 - remove not working optimization in gimplification This removes a premature and not working optimization from the gimplifier. When gimplification is requested not to produce a SSA name we try to avoid generating a copy when we did so anyway but instead replace the LHS of its definition. But that only works in case there are no uses of the SSA name already which is something we cannot easily check, so the following removes said optimization. Statistics on the whole bootstrap shows we hit this optimization only for libiberty/cp-demangle.c and overall we have 21652112 gimplifications where just 240 copies are elided. Preserving the optimization would require scanning the original expression and the pre and post sequences for SSA names and uses, that seems excessive to avoid these 240 copies. 2021-06-22 Richard Biener <rguenther@suse.de> PR middle-end/101156 * gimplify.c (gimplify_expr): Remove premature incorrect optimization. * gcc.dg/pr101156.c: New testcase.
Fixed on trunk sofar, unsure if worth backporting - we've not hit this in 5 years ;)
The releases/gcc-11 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:9e1173009150086a927a6f0e001fd04c5cac54cb commit r11-8698-g9e1173009150086a927a6f0e001fd04c5cac54cb Author: Richard Biener <rguenther@suse.de> Date: Tue Jun 22 12:13:44 2021 +0200 middle-end/101156 - remove not working optimization in gimplification This removes a premature and not working optimization from the gimplifier. When gimplification is requested not to produce a SSA name we try to avoid generating a copy when we did so anyway but instead replace the LHS of its definition. But that only works in case there are no uses of the SSA name already which is something we cannot easily check, so the following removes said optimization. Statistics on the whole bootstrap shows we hit this optimization only for libiberty/cp-demangle.c and overall we have 21652112 gimplifications where just 240 copies are elided. Preserving the optimization would require scanning the original expression and the pre and post sequences for SSA names and uses, that seems excessive to avoid these 240 copies. 2021-06-22 Richard Biener <rguenther@suse.de> PR middle-end/101156 * gimplify.c (gimplify_expr): Remove premature incorrect optimization. * gcc.dg/pr101156.c: New testcase. (cherry picked from commit b4e21c80462682c4e6e5e487fe87107b27f8b4bd)
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Fixed in GCC 11.2.