https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450
--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
Like the following - what's missing in realizing full opportunities is
eventually allowing vector integer modes for the move as well, like with
(int_mode_for_size (ilen * 8, 0).exists (&mode)
|| mode_for_size (ilen * 8, MODE_VECTOR_INT, 0).exists (&mode))
but the previous implementation didn't do that and so it's not part of a
fix for this particular problem. It would also require building a
vector type of course.
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 6fea8a6f9fd..474d0f44375 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1001,9 +1001,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
return false;
scalar_int_mode mode;
- tree type = lang_hooks.types.type_for_size (ilen * 8, 1);
- if (type
- && is_a <scalar_int_mode> (TYPE_MODE (type), &mode)
+ if (int_mode_for_size (ilen * 8, 0).exists (&mode)
&& GET_MODE_SIZE (mode) * BITS_PER_UNIT == ilen * 8
&& have_insn_for (SET, mode)
/* If the destination pointer is not aligned we must be able
@@ -1013,6 +1011,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
|| (optab_handler (movmisalign_optab, mode)
!= CODE_FOR_nothing)))
{
+ tree type = build_nonstandard_integer_type (ilen * 8, 1);
tree srctype = type;
tree desttype = type;
if (src_align < GET_MODE_ALIGNMENT (mode))