On Thu, Jan 18, 2024 at 01:57:49PM +0100, Richard Biener wrote: > > - RTL expansion expectes TARGET_MEM_REF to always address actual > > memory. */ > > + RTL expansion expectes TARGET_MEM_REF to always address actual memory. > > + Also, force to stack non-BLKmode vars accessed through > > VIEW_CONVERT_EXPR > > + to BLKmode BITINT_TYPEs. */ > > else if (TREE_CODE (t) == TARGET_MEM_REF > > || (TREE_CODE (t) == MEM_REF > > && TYPE_SIZE (TREE_TYPE (t)) > > - && POLY_INT_CST_P (TYPE_SIZE (TREE_TYPE (t))))) > > + && POLY_INT_CST_P (TYPE_SIZE (TREE_TYPE (t)))) > > + || (TREE_CODE (t) == VIEW_CONVERT_EXPR > > + && TREE_CODE (TREE_TYPE (t)) == BITINT_TYPE > > + && TYPE_MODE (TREE_TYPE (t)) == BLKmode)) > > I'm still not getting what's special about BITINT_TYPE here so > shouldn't that apply to all BLKmode V_C_E? But sure we can for > now just handle BITINT_TYPE. > > That hunk looks OK to me.
The == BITINT_TYPE check is non-essential, was just trying to keep existing behavior otherwise. I can certainly drop that. > > --- gcc/expr.cc.jj 2024-01-12 10:07:58.194851657 +0100 > > +++ gcc/expr.cc 2024-01-18 13:38:19.677556646 +0100 > > @@ -12382,6 +12382,17 @@ expand_expr_real_1 (tree exp, rtx target > > } > > } > > > > + /* Ensure non-BLKmode array VAR_DECLs VCEd to BLKmode BITINT_TYPE > > + aren't promoted to registers. */ > > + if (op0 == NULL_RTX > > + && mode == BLKmode > > + && TREE_CODE (type) == BITINT_TYPE > > + && VAR_P (treeop0) > > + && DECL_MODE (treeop0) != BLKmode > > + && DECL_RTL_SET_P (treeop0) > > + && MEM_P (DECL_RTL (treeop0))) > > + op0 = adjust_address (DECL_RTL (treeop0), BLKmode, 0); > > + > > if (!op0) > > op0 = expand_expr_real (treeop0, NULL_RTX, VOIDmode, modifier, > > NULL, inner_reference_p); > > So we're now sure we have MEM_P (op0) after expand_expr_real, > even without this change, right? What's wrong with the > suggestion to use I wasn't sure if VAR_P (treeop0) && MEM_P (DECL_RTL (treeop0)) implies that expand_expr_real will return a MEM, but I'm not able to find a path in which it would return something different, so maybe ok. > if (mode == GET_MODE (op0) || (mode == BLKmode && MEM_P (op0)) > > thus not run into any of the special-casing? We're doing just It is true the later code will then do: > > op0 = adjust_address (op0, mode, 0); so perhaps it is ok as you wrote it (though perhaps adding it as a separate else if would allow a separate comment). Jakub