diff options
author | Alexandre Oliva <oliva@adacore.com> | 2023-12-11 15:09:28 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2023-12-11 15:31:50 -0300 |
commit | a8a3d832e609501002dee54150abfd96a28fe532 (patch) | |
tree | bed9291469dded08d704bfb3c2ff47a72a7b284f /gcc/expr.cc | |
parent | 1e2ea685bdea9aa65da2bf4137264d14f38a6f0b (diff) | |
download | gcc-a8a3d832e609501002dee54150abfd96a28fe532.zip gcc-a8a3d832e609501002dee54150abfd96a28fe532.tar.gz gcc-a8a3d832e609501002dee54150abfd96a28fe532.tar.bz2 |
-finline-stringops: avoid too-wide smallest_int_mode_for_size [PR112784]
smallest_int_mode_for_size may abort when the requested mode is not
available. Call int_mode_for_size instead, that signals the
unsatisfiable request in a more graceful way.
for gcc/ChangeLog
PR middle-end/112784
* expr.cc (emit_block_move_via_loop): Call int_mode_for_size
for maybe-too-wide sizes.
(emit_block_cmp_via_loop): Likewise.
for gcc/testsuite/ChangeLog
PR middle-end/112784
* gcc.target/i386/avx512cd-inline-stringops-pr112784.c: New.
Diffstat (limited to 'gcc/expr.cc')
-rw-r--r-- | gcc/expr.cc | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/gcc/expr.cc b/gcc/expr.cc index 4686cac..9fef2bf 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -2449,15 +2449,14 @@ emit_block_move_via_loop (rtx x, rtx y, rtx size, } emit_move_insn (iter, iter_init); - scalar_int_mode int_move_mode - = smallest_int_mode_for_size (incr * BITS_PER_UNIT); - if (GET_MODE_BITSIZE (int_move_mode) != incr * BITS_PER_UNIT) + opt_scalar_int_mode int_move_mode + = int_mode_for_size (incr * BITS_PER_UNIT, 1); + if (!int_move_mode.exists (&move_mode) + || GET_MODE_BITSIZE (int_move_mode.require ()) != incr * BITS_PER_UNIT) { move_mode = BLKmode; gcc_checking_assert (can_move_by_pieces (incr, align)); } - else - move_mode = int_move_mode; x_addr = force_operand (XEXP (x, 0), NULL_RTX); y_addr = force_operand (XEXP (y, 0), NULL_RTX); @@ -2701,16 +2700,15 @@ emit_block_cmp_via_loop (rtx x, rtx y, rtx len, tree len_type, rtx target, iter = gen_reg_rtx (iter_mode); emit_move_insn (iter, iter_init); - scalar_int_mode int_cmp_mode - = smallest_int_mode_for_size (incr * BITS_PER_UNIT); - if (GET_MODE_BITSIZE (int_cmp_mode) != incr * BITS_PER_UNIT - || !can_compare_p (NE, int_cmp_mode, ccp_jump)) + opt_scalar_int_mode int_cmp_mode + = int_mode_for_size (incr * BITS_PER_UNIT, 1); + if (!int_cmp_mode.exists (&cmp_mode) + || GET_MODE_BITSIZE (int_cmp_mode.require ()) != incr * BITS_PER_UNIT + || !can_compare_p (NE, cmp_mode, ccp_jump)) { cmp_mode = BLKmode; gcc_checking_assert (incr != 1); } - else - cmp_mode = int_cmp_mode; /* Save the base addresses. */ x_addr = force_operand (XEXP (x, 0), NULL_RTX); |