From b66fd4fc3777e1d072a63529b70b2ff777e6efcb Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 21 Aug 2017 14:52:43 +0000 Subject: [PATCH] Simplify pad_below implementation This patch simplifies the alignment calculations in pad_below. The first arm of the "if" was: - taking GET_MODE_BITSIZE (always equal to GET_MODE_SIZE * BITS_PER_UNIT), - rounding up to the next multiple of PARM_BOUNDARY - converting bits to bytes and - subtracting the GET_MODE_SIZE so was in effect calculating the number of bytes needed to round GET_MODE_SIZE up to (PARM_BOUNDARY / BITS_PER_UNIT). That can be done more directly as -size & (align - 1), which is easier to convert to variable-sized modes. 2017-08-21 Richard Sandiford Alan Hayward David Sherwood gcc/ * function.c (pad_below): Simplify padding calculation. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r251233 --- gcc/ChangeLog | 6 ++++++ gcc/function.c | 13 ++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4c0b975..26b34a3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,12 @@ Alan Hayward David Sherwood + * function.c (pad_below): Simplify padding calculation. + +2017-08-21 Richard Sandiford + Alan Hayward + David Sherwood + * target.def (function_prologue): Remove frame size argument. (function_epilogue): Likewise. * doc/tm.texi: Regenerate. diff --git a/gcc/function.c b/gcc/function.c index 20c287b..7fce0c5 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4322,21 +4322,16 @@ pad_to_arg_alignment (struct args_size *offset_ptr, int boundary, static void pad_below (struct args_size *offset_ptr, machine_mode passed_mode, tree sizetree) { + unsigned int align = PARM_BOUNDARY / BITS_PER_UNIT; if (passed_mode != BLKmode) - { - if (GET_MODE_BITSIZE (passed_mode) % PARM_BOUNDARY) - offset_ptr->constant - += (((GET_MODE_BITSIZE (passed_mode) + PARM_BOUNDARY - 1) - / PARM_BOUNDARY * PARM_BOUNDARY / BITS_PER_UNIT) - - GET_MODE_SIZE (passed_mode)); - } + offset_ptr->constant += -GET_MODE_SIZE (passed_mode) & (align - 1); else { if (TREE_CODE (sizetree) != INTEGER_CST - || (TREE_INT_CST_LOW (sizetree) * BITS_PER_UNIT) % PARM_BOUNDARY) + || (TREE_INT_CST_LOW (sizetree) & (align - 1)) != 0) { /* Round the size up to multiple of PARM_BOUNDARY bits. */ - tree s2 = round_up (sizetree, PARM_BOUNDARY / BITS_PER_UNIT); + tree s2 = round_up (sizetree, align); /* Add it in. */ ADD_PARM_SIZE (*offset_ptr, s2); SUB_PARM_SIZE (*offset_ptr, sizetree); -- 2.7.4