[01/12] Update alignment_for_piecewise_move

Message ID 20210429125415.1634118-2-hjl.tools@gmail.com
State New
Headers show
Series
  • Allow TImode/OImode/XImode in op_by_pieces operations
Related show

Commit Message

Hongtao Liu via Gcc-patches April 29, 2021, 12:54 p.m.
alignment_for_piecewise_move is called only with MOVE_MAX_PIECES or
STORE_MAX_PIECES, which are the number of bytes at a time that we
can move or store efficiently.  We should call mode_for_size without
limit to MAX_FIXED_MODE_SIZE, which is an integer expression for the
size in bits of the largest integer machine mode that should actually
be used, may be smaller than MOVE_MAX_PIECES or STORE_MAX_PIECES, which
may use vector.

	* expr.c (alignment_for_piecewise_move): Call mode_for_size
	without limit to MAX_FIXED_MODE_SIZE.
---
 gcc/expr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.31.1

Comments

Hongtao Liu via Gcc-patches April 30, 2021, 8:59 a.m. | #1
"H.J. Lu via Gcc-patches" <gcc-patches@gcc.gnu.org> writes:
> alignment_for_piecewise_move is called only with MOVE_MAX_PIECES or

> STORE_MAX_PIECES, which are the number of bytes at a time that we

> can move or store efficiently.  We should call mode_for_size without

> limit to MAX_FIXED_MODE_SIZE, which is an integer expression for the

> size in bits of the largest integer machine mode that should actually

> be used, may be smaller than MOVE_MAX_PIECES or STORE_MAX_PIECES, which

> may use vector.

>

> 	* expr.c (alignment_for_piecewise_move): Call mode_for_size

> 	without limit to MAX_FIXED_MODE_SIZE.


OK.  I agree it doesn't make sense to apply the limit here, given
that the size is entirely under the target's control anyway.
And it should be safe, since any target that sets MOVE_MAX_PIECES
or STORE_MAX_PIECES higher than MAX_FIXED_MODE_SIZE would trigger
the require () assert.

Thanks,
Richard

> ---

>  gcc/expr.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/gcc/expr.c b/gcc/expr.c

> index e0167b77410..b4c110f8c17 100644

> --- a/gcc/expr.c

> +++ b/gcc/expr.c

> @@ -746,7 +746,7 @@ static unsigned int

>  alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align)

>  {

>    scalar_int_mode tmode

> -    = int_mode_for_size (max_pieces * BITS_PER_UNIT, 1).require ();

> +    = int_mode_for_size (max_pieces * BITS_PER_UNIT, 0).require ();

>  

>    if (align >= GET_MODE_ALIGNMENT (tmode))

>      align = GET_MODE_ALIGNMENT (tmode);

Patch

diff --git a/gcc/expr.c b/gcc/expr.c
index e0167b77410..b4c110f8c17 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -746,7 +746,7 @@  static unsigned int
 alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align)
 {
   scalar_int_mode tmode
-    = int_mode_for_size (max_pieces * BITS_PER_UNIT, 1).require ();
+    = int_mode_for_size (max_pieces * BITS_PER_UNIT, 0).require ();
 
   if (align >= GET_MODE_ALIGNMENT (tmode))
     align = GET_MODE_ALIGNMENT (tmode);