diff --git a/gcc/gimple-ssa-store-merging.cc b/gcc/gimple-ssa-store-merging.cc index cb0cb5f42f6..7dba4a7a781 100644 --- a/gcc/gimple-ssa-store-merging.cc +++ b/gcc/gimple-ssa-store-merging.cc @@ -363,7 +363,7 @@ init_symbolic_number (struct symbolic_number *n, tree src) the answer. If so, REF is that memory source and the base of the memory area accessed and the offset of the access from that base are recorded in N. */ -bool +static bool find_bswap_or_nop_load (gimple *stmt, tree ref, struct symbolic_number *n) { /* Leaf node is an array or component ref. Memorize its base and @@ -610,7 +610,9 @@ find_bswap_or_nop_1 (gimple *stmt, struct symbolic_number *n, int limit) gimple *rhs1_stmt, *rhs2_stmt, *source_stmt1; enum gimple_rhs_class rhs_class; - if (!limit || !is_gimple_assign (stmt)) + if (!limit + || !is_gimple_assign (stmt) + || stmt_can_throw_internal (cfun, stmt)) return NULL; rhs1 = gimple_assign_rhs1 (stmt); diff --git a/gcc/testsuite/g++.dg/pr113673.C b/gcc/testsuite/g++.dg/pr113673.C new file mode 100644 index 00000000000..11489777f5b --- /dev/null +++ b/gcc/testsuite/g++.dg/pr113673.C @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fnon-call-exceptions -ftrapv" } */ + +struct s { ~s(); }; +void +h (unsigned char *data, int c) +{ + s a1; + while (c) + { + int m = *data++ << 8; + m += *data++; + } +}