https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79805
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Author: jakub Date: Fri Mar 3 19:32:01 2017 New Revision: 245882 URL: https://gcc.gnu.org/viewcvs?rev=245882&root=gcc&view=rev Log: PR middle-end/79805 * internal-fn.def (ATOMIC_BIT_TEST_AND_SET, ATOMIC_BIT_TEST_AND_RESET, ATOMIC_BIT_TEST_AND_COMPLEMENT, ATOMIC_COMPARE_EXCHANGE): Remove ECF_NOTHROW. * gimple-fold.c (fold_builtin_atomic_compare_exchange): Set gimple_call_nothrow_p flag based on whether original builtin can throw. If it can, emit following stmts on the fallthrough edge. * tree-ssa-ccp.c (optimize_atomic_bit_test_and): Similarly, except don't create new bb if inserting just debug stmts on the edge, try to insert them on the fallthru bb or just reset debug stmts. * g++.dg/opt/pr79805.C: New test. Added: trunk/gcc/testsuite/g++.dg/opt/pr79805.C Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-fold.c trunk/gcc/internal-fn.def trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-ccp.c