http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16351
--- Comment #12 from Jeffrey A. Law <law at redhat dot com> --- gimple-ssa-isolate-paths.c has the necessary logic to catch a lot of this kind of stuff now. From what I can tell, it would catch everything properly in the attached testcase.