This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][GCC][mid-end] Allow larger copies when target supports unaligned access [Patch (1/2)]
- From: Peter Bergner <bergner at vnet dot ibm dot com>
- To: Alan Modra <amodra at gmail dot com>, Tamar Christina <Tamar dot Christina at arm dot com>
- Cc: Richard Biener <rguenther at suse dot de>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>, "law at redhat dot com" <law at redhat dot com>, "ian at airs dot com" <ian at airs dot com>
- Date: Fri, 30 Mar 2018 11:16:30 -0500
- Subject: Re: [PATCH][GCC][mid-end] Allow larger copies when target supports unaligned access [Patch (1/2)]
- References: <20171114160235.GA30036@arm.com> <alpine.LSU.2.20.1711150922560.12252@zhemvz.fhfr.qr> <HE1PR08MB050743F129A07EF731DA88A6FF290@HE1PR08MB0507.eurprd08.prod.outlook.com> <alpine.LSU.2.20.1711151347450.12252@zhemvz.fhfr.qr> <20171115155237.GA30502@arm.com> <alpine.LSU.2.20.1711160858100.12252@zhemvz.fhfr.qr> <20171116114254.GA11570@arm.com> <alpine.LSU.2.20.1711161254130.12252@zhemvz.fhfr.qr> <20171116152701.GA15229@arm.com> <20180329143525.GA3812@bubble.grove.modra.org>
On 3/29/18 9:35 AM, Alan Modra wrote:
> 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.
FYI, I received an automated response saying Tamar is away on vacation
with no return date specified. That means he won't be able to revert
the patch. What do we do now?
Peter