On Thu, Nov 16, 2017 at 03:27:01PM +0000, Tamar Christina wrote:
> --- a/gcc/expr.c
> +++ b/gcc/expr.c
> @@ -2769,7 +2769,9 @@ copy_blkmode_to_reg (machine_mode mode, tree src)
>  
>    n_regs = (bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
>    dst_words = XALLOCAVEC (rtx, n_regs);
> -  bitsize = MIN (TYPE_ALIGN (TREE_TYPE (src)), BITS_PER_WORD);
> +  bitsize = BITS_PER_WORD;
> +  if (targetm.slow_unaligned_access (word_mode, TYPE_ALIGN (TREE_TYPE 
> (src))))
> +    bitsize = MIN (TYPE_ALIGN (TREE_TYPE (src)), BITS_PER_WORD);
>  
>    /* Copy the structure BITSIZE bits at a time.  */
>    for (bitpos = 0, xbitpos = padding_correction;

I believe this patch is wrong.  Please revert.  See the PR84762 testcase.

There are two problems.  Firstly, if padding_correction is non-zero,
then xbitpos % BITS_PER_WORD is non-zero and in

      store_bit_field (dst_word, bitsize, xbitpos % BITS_PER_WORD,
                       0, 0, word_mode,
                       extract_bit_field (src_word, bitsize,
                                          bitpos % BITS_PER_WORD, 1,
                                          NULL_RTX, word_mode, word_mode,
                                          false, NULL),
                       false);

the stored bit-field exceeds the destination register size.  You could
fix that by making bitsize the gcd of bitsize and padding_correction.

However, that doesn't fix the second problem which is that the
extracted bit-field can exceed the source size.  That will result in
rubbish being read into a register.

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to