diff options
author | Tamar Christina <tamar.christina@arm.com> | 2024-02-07 10:58:25 +0000 |
---|---|---|
committer | Tamar Christina <tamar.christina@arm.com> | 2024-02-07 10:58:25 +0000 |
commit | 8f6ed71d8fff3c3c6249651a72aee084e31ffb9e (patch) | |
tree | abc73dbd238934914851f11225c49ad41df93b23 /gcc/gimple-iterator.h | |
parent | 194d0956ef5992d4e453bde3eb5772dc077f610c (diff) | |
download | gcc-8f6ed71d8fff3c3c6249651a72aee084e31ffb9e.zip gcc-8f6ed71d8fff3c3c6249651a72aee084e31ffb9e.tar.gz gcc-8f6ed71d8fff3c3c6249651a72aee084e31ffb9e.tar.bz2 |
middle-end: fix ICE when moving statements to empty BB [PR113731]
We use gsi_move_before (&stmt_gsi, &dest_gsi); to request that the new statement
be placed before any other statement. Typically this then moves the current
pointer to be after the statement we just inserted.
However it looks like when the BB is empty, this does not happen and the CUR
pointer stays NULL. There's a comment in the source of gsi_insert_before that
explains:
/* If CUR is NULL, we link at the end of the sequence (this case happens
This adds a default parameter to gsi_move_before to allow us to control where
the insertion happens.
gcc/ChangeLog:
PR tree-optimization/113731
* gimple-iterator.cc (gsi_move_before): Take new parameter for update
method.
* gimple-iterator.h (gsi_move_before): Default new param to
GSI_SAME_STMT.
* tree-vect-loop.cc (move_early_exit_stmts): Call gsi_move_before with
GSI_NEW_STMT.
gcc/testsuite/ChangeLog:
PR tree-optimization/113731
* gcc.dg/vect/vect-early-break_111-pr113731.c: New test.
Diffstat (limited to 'gcc/gimple-iterator.h')
-rw-r--r-- | gcc/gimple-iterator.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h index 2e83a96..78014a4 100644 --- a/gcc/gimple-iterator.h +++ b/gcc/gimple-iterator.h @@ -86,7 +86,8 @@ extern gimple_stmt_iterator gsi_for_stmt (gimple *); extern gimple_stmt_iterator gsi_for_stmt (gimple *, gimple_seq *); extern gphi_iterator gsi_for_phi (gphi *); extern void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *); -extern void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *); +extern void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *, + gsi_iterator_update = GSI_SAME_STMT); extern void gsi_move_to_bb_end (gimple_stmt_iterator *, basic_block); extern void gsi_insert_on_edge (edge, gimple *); extern void gsi_insert_seq_on_edge (edge, gimple_seq); |