https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110705

            Bug ID: 110705
           Summary: ICE at -O2 and above: in gimplify_modify_expr, at
                    gimplify.cc:6255 (on GCC-12.x)
           Product: gcc
           Version: 12.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi,

GCC-12.0 to GCC-12.3 versions fail to compile the following code.

$cat small.c
struct a {
  long b;
};
union d {
  struct a b;
  int e;
}v;
long c;
int f;
static void g(union d h, long i) {
  while (1)
    switch (c)
    case 4:
      if (h.e)
        c = 4;
}
void j(union d *h) {
  if (f)
    g(*h, h->b.b);
}
void k() { union d *h = &v; j(h); }

$gcc-12 -w -O2 small.c
during IPA pass: inline
In function ‘j.part.0.isra’:
cc1: internal compiler error: in gimplify_modify_expr, at gimplify.cc:6255
0x664d30 gimplify_modify_expr
        ../../gcc/gimplify.cc:6255
0x97daf3 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:15098
0x982c3a gimplify_stmt(tree_node**, gimple**)
        ../../gcc/gimplify.cc:7151
0x982c3a gimplify_and_add(tree_node*, gimple**)
        ../../gcc/gimplify.cc:496
0x982c3a internal_get_tmp_var
        ../../gcc/gimplify.cc:649
0x982ed1 get_initialized_tmp_var(tree_node*, gimple**, gimple**, bool)
        ../../gcc/gimplify.cc:681
0x982ed1 prepare_gimple_addressable
        ../../gcc/gimplify.cc:4580
0x983630 gimplify_addr_expr
        ../../gcc/gimplify.cc:6500
0x97dee8 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ../../gcc/gimplify.cc:15145
0x9952bf force_gimple_operand_1(tree_node*, gimple**, bool (*)(tree_node*),
tree_node*)
        ../../gcc/gimplify-me.cc:78
0x9953ff force_gimple_operand_gsi_1(gimple_stmt_iterator*, tree_node*, bool
(*)(tree_node*), tree_node*, bool, gsi_iterator_update)
        ../../gcc/gimplify-me.cc:115
0x9953ff force_gimple_operand_gsi(gimple_stmt_iterator*, tree_node*, bool,
tree_node*, bool, gsi_iterator_update)
        ../../gcc/gimplify-me.cc:141
0xa31bf9 ipa_param_adjustments::modify_call(cgraph_edge*, bool)
        ../../gcc/ipa-param-manipulation.cc:827
0x806a13 cgraph_edge::redirect_call_stmt_to_callee(cgraph_edge*)
        ../../gcc/cgraph.cc:1531
0x9f5ad4 inline_transform(cgraph_node*)
        ../../gcc/ipa-inline-transform.cc:783
0xb4248b execute_one_ipa_transform_pass
        ../../gcc/passes.cc:2330
0xb4248b execute_all_ipa_transforms(bool)
        ../../gcc/passes.cc:2393
0x80ce5f cgraph_node::expand()
        ../../gcc/cgraphunit.cc:1828
0x80ce5f cgraph_node::expand()
        ../../gcc/cgraphunit.cc:1788
0x80e39e expand_all_functions
        ../../gcc/cgraphunit.cc:1999
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.


$gcc-12 -v
Using built-in specs.
COLLECT_GCC=gcc-12
COLLECT_LTO_WRAPPER=/home/haoxin/haoxin-data/compilers/gcc-12.1-lastest/build/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure
--prefix=/home/haoxin/haoxin-data/compilers/gcc/build --enable-bootstrap
--enable-checking=release --enable-languages=c,c++ --enable-multilib
--program-suffix=-trunk : (reconfigured) ../configure
--prefix=/home/haoxin/haoxin-data/compilers/gcc/build --enable-bootstrap
--enable-checking=release --enable-languages=c,c++ --enable-multilib
--program-suffix=-trunk
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.1 20220424 (experimental) (GCC) 

GCC-12.3 on Godblot: https://godbolt.org/z/a3oxjdxeo

Thanks,
Haoxin

Reply via email to