On Wed, Jul 12, 2017 at 11:24 PM, Segher Boessenkool <seg...@kernel.crashing.org> wrote: > On Wed, Jul 12, 2017 at 01:34:01PM -0500, Bill Schmidt wrote: >> Although I said this was invalid code, it really isn't -- it's legal code. >> It's more of an ice-on-stupid-code situation. :) So probably you should >> remove the "invalid" language from the commentary. Sorry for misleading you. > > We could fold this to nothing (if there are no side effects), but it > would be better if we made stupid code slower instead of faster ;-)
Well, optimization opportunities are not always obvious to the writer. Iff the builtins have no side-effects besides the return value the backend should mark them PURE or CONST and you wouldn't run into this situation. But yes, simply folding to GIMPLE_NOP is the appropriate thing when you want to paper over the above deficit in the folding routine. gsi_replace (si_p, gimple_build_nop (), false); note you'll eventually wreck virtual operands so before do unlink_stmt_vdef (gsi_stmt (gsi)); which may have it's own share of issues (folding may not look at SSA immediate uses...). So better fixup builtin attributes! Richard. > > Segher