This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, GCC/ARM/gcc-7-branch] Backport PR71607
- From: Prakhar Bahuguna <prakhar dot bahuguna at arm dot com>
- To: <richard dot sandiford at linaro dot org>
- Cc: <gcc-patches at gcc dot gnu dot org>, <nd at arm dot com>
- Date: Thu, 1 Jun 2017 11:20:55 +0100
- Subject: Re: [PATCH, GCC/ARM/gcc-7-branch] Backport PR71607
- Authentication-results: sourceware.org; auth=none
- Authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=arm.com;
- Nodisclaimer: True
- References: <20170525132626.t536vqs4yhhtvwyh@e107464-lin.cambridge.arm.com> <87o9u9mo9v.fsf@linaro.org> <20170531124844.y263emgdovlu7z2f@e107464-lin.cambridge.arm.com> <87fuflmar4.fsf@linaro.org> <20170531153845.b23jxwtbrovcxje7@e107464-lin.cambridge.arm.com> <87lgpcz10s.fsf@linaro.org>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 01/06/2017 07:15:47, Richard Sandiford wrote:
> Prakhar Bahuguna <prakhar.bahuguna@arm.com> writes:
> > On 31/05/2017 14:11:43, Richard Sandiford wrote:
> >> Prakhar Bahuguna <prakhar.bahuguna@arm.com> writes:
> >> > On 31/05/2017 09:19:40, Richard Sandiford wrote:
> >> >> const_ints are supposed to be stored in sign-extended form, so a 32-bit
> >> >> integer with the MSB set should be 0xffffffff80000000|x instead of
> >> >> 0x80000000|x. It's a bug if you have one where that isn't true.
> >> >>
> >> >> In the patch it looks like this could come from:
> >> >> ...these two splits, where the GEN_INTs should probably be:
> >> >>
> >> >> gen_int_mode (..., SImode);
> >> >>
> >> >> instead.
> >> >
> >> > Hi Richard, thanks for the tip. Is there a test case that could produce an
> >> > incorrect result? I've attempted to create one using negative doubles and
> >> > floats but haven't succeeded.
> >>
> >> Just to check, are you testing with --enable-checking=yes,rtl?
> >>
> >> When the values you tried were split, did you get the sign-extended form
> >> or the zero-extended form?
> >>
> >> Thanks,
> >> Richard
> >
> > I've now rebuilt with --enable-checking=yes,rtl and it appears that the split
> > values are being correctly sign-extended in the rtl and appear correctly in the
> > assembly.
> >
> > However, if you believe it is safer to use gen_int_mode(), I'll respin the
> > patch accordingly.
>
> Yeah, I think it would be safer. But if they were already correctly
> sign-extended, then what did you mean by:
>
> Also the pattern for splitting 32-bit immediates had to be changed, it
> was not accepting unsigned 32-bit unsigned integers with the MSB
> set. I believe const_int_operand expects the mode of the operand to be
> set to VOIDmode and not SImode. I have only changed it in the patterns
> that were affecting this code, though I suggest looking into changing
> it in the rest of the ARM backend.
>
> Thanks,
> Richard
This part of the patch was written by Andre. After checking with him, it seems
that some of the confusion arises from the comment on real_to_target() which
states "There are always 32 bits in each long, no matter the size of the host
long". While this may imply the value is zero-extended on hosts with wider
longs, it seems like the value is always correctly sign-extended and thus
gen_int_mode() should be unnecessary.
As for why VOIDmode is used with the values casted to int, there is a reason
for why it is done this way to get it working but this has been long-forgotten.
I only have the code and this message to rely on.
--
Prakhar Bahuguna