The following patch fixes missing EH info transfer after folding.
Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2019-03-25 Richard Biener <rguent...@suse.de> PR tree-optimization/89802 * tree-ssa-math-opts.c (convert_mult_to_fma_1): Properly move EH data to folded stmt. * g++.dg/tree-ssa/pr89802.C: New testcase. Index: gcc/testsuite/g++.dg/tree-ssa/pr89802.C =================================================================== --- gcc/testsuite/g++.dg/tree-ssa/pr89802.C (nonexistent) +++ gcc/testsuite/g++.dg/tree-ssa/pr89802.C (working copy) @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-O2 -fnon-call-exceptions" } +// { dg-additional-options "-mfma" { target x86_64-*-* i?86-*-* } } + +struct ef +{ + ef (double xy) : m6 (xy) + { + } + + ~ef () + { + } + + double m6; +}; + +ef +operator- (ef &db, ef oa) +{ + return db.m6 - oa.m6; +} + +ef +vu (ef &db) +{ + return db - ef (db.m6 * 1.1); +} Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c (revision 269905) +++ gcc/tree-ssa-math-opts.c (working copy) @@ -2917,8 +2917,13 @@ convert_mult_to_fma_1 (tree mul_result, gsi_replace (&gsi, fma_stmt, true); /* Follow all SSA edges so that we generate FMS, FNMA and FNMS regardless of where the negation occurs. */ + gimple *orig_stmt = gsi_stmt (gsi); if (fold_stmt (&gsi, follow_all_ssa_edges)) - update_stmt (gsi_stmt (gsi)); + { + if (maybe_clean_or_replace_eh_stmt (orig_stmt, gsi_stmt (gsi))) + gcc_unreachable (); + update_stmt (gsi_stmt (gsi)); + } if (dump_file && (dump_flags & TDF_DETAILS)) {