https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98190
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, do we need to special case MEM_REF stores that store all bits (i.e. bitpos
0 bitsize equal to mode bitsize) into non-MEM variables which are promoted?
Something like:
--- gcc/expr.c.jj 2020-12-02 11:40:47.000000000 +0100
+++ gcc/expr.c 2020-12-08 19:57:05.147004740 +0100
@@ -5451,6 +5451,14 @@ expand_assignment (tree to, tree from, b
mode1, to_rtx, to, from,
reversep))
result = NULL;
+ else if (TREE_CODE (to) == MEM_REF
+ && !REF_REVERSE_STORAGE_ORDER (to)
+ && mem_ref_refers_to_non_mem_p (to)
+ && SUBREG_P (to_rtx)
+ && SUBREG_PROMOTED_VAR_P (to_rtx)
+ && known_eq (bitpos, 0)
+ && known_eq (bitsize, GET_MODE_BITSIZE (GET_MODE (to_rtx))))
+ result = store_expr (from, to_rtx, 0, nontemporal, false);
else
result = store_field (to_rtx, bitsize, bitpos,
bitregion_start, bitregion_end,
Not sure if it additionally doesn't have to check same mode, or if e.g. should
wrap from into a VCE if it has significantly different type.
It will not handle reverse storage order though.