I've put the preparation stmt in the wrong place. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/109848 * tree-ssa-forwprop.cc (pass_forwprop::execute): Put the TARGET_MEM_REF address preparation before the store, not before the CTOR. --- gcc/tree-ssa-forwprop.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index e63d2ab82c9..06f19868ade 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -3841,7 +3841,10 @@ pass_forwprop::execute (function *fun) if (auto_var_p (use_lhs)) DECL_NOT_GIMPLE_REG_P (use_lhs) = 1; else if (TREE_CODE (use_lhs) == TARGET_MEM_REF) - use_lhs = prepare_target_mem_ref_lvalue (use_lhs, &gsi); + { + gimple_stmt_iterator gsi2 = gsi_for_stmt (use_stmt); + use_lhs = prepare_target_mem_ref_lvalue (use_lhs, &gsi2); + } for (unsigned HOST_WIDE_INT bi = 0; bi < n; bi += elt_w) { unsigned HOST_WIDE_INT ci = bi / elt_w; -- 2.35.3