On Fri, 12 Jan 2018, Jakub Jelinek wrote: > On Fri, Jan 12, 2018 at 09:16:35AM +0100, Richard Biener wrote: > > Or another workaround would be to make sure non-constant sizepos > > stay non-constant by doing sth like the following? FEs can mark > > expressions as TREE_CONSTANT if they don't want this behavior > > for things that might optimize to constants during gimplification. > > Not against that, though in that case perhaps it can be even just > + if (is_gimple_constant (*expr_p)) > + *expr_p = get_initialized_tmp_var (*expr_p, stmt_p, NULL, false); > with a comment, because the function has an early exit for: > if (is_gimple_sizepos (expr)) > return;
But say (static const foo = 1) + 2 aka foo + 2 marked with TREE_CONSTANT isn't is_gimple_sizepos. But maybe we require FEs to fold TREE_CONSTANT expressions prior to gimplification and not rely on the gimplifier here? > Would you be ok with that? In that case I'd probably do a bootstrap/regtest > with statistics gathering on when this happens, dunno about Ada and other > FEs how often they do this kind of thing. That would certainly be interesting (also whether they'd be TREE_CONSTANT). is_gimple_sizepos is also somehwat suspicious as it would allow a global VAR_DECL as valid, not just sth that is is_gimple_reg. Richard.