https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70184
--- Comment #7 from ktkachov at gcc dot gnu.org --- (In reply to Richard Biener from comment #4) > With TER we delay expanding of (unsigned b) until you require its expansion > during asm op expansion (and thus may be interleaved with asm expansion > code). > > I believe we had this issue in the past for other archs and libcalls. Don't > remember what the solution there was though ;) IIRC it was libcalls > expanded during libcall expansion or so like for a + (b * c) and both > + and * resulting in a libcall. I see that tree-ssa-ter.c:find_replaceable_in_bb already tries to avoid replacing across calls but it doesn't take into account expressions that expand into libcalls and doesn't consider register variables. I don't think there's an easy way to query from gimple if an arbitrary expression will result in a libcall, maybe the solution here is to not allow TER across definitions of register variables? Or is that too big a hammer?