This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PR tree-optimization/64946] Push integer type conversion to ABS_EXPR argument when possible.
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bernd Schmidt <bschmidt at redhat dot com>,Matthew Wahab <matthew dot wahab at foss dot arm dot com>,Joseph Myers <joseph at codesourcery dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 11 Jan 2016 18:46:23 +0100
- Subject: Re: [PR tree-optimization/64946] Push integer type conversion to ABS_EXPR argument when possible.
- Authentication-results: sourceware.org; auth=none
- References: <568FDB72 dot 70109 at foss dot arm dot com> <alpine dot DEB dot 2 dot 10 dot 1601082217580 dot 22470 at digraph dot polyomino dot org dot uk> <5693D944 dot 8060308 at foss dot arm dot com> <5693DA11 dot 4040006 at redhat dot com>
On January 11, 2016 5:36:33 PM GMT+01:00, Bernd Schmidt <bschmidt@redhat.com> wrote:
>On 01/11/2016 05:33 PM, Matthew Wahab wrote:
>>
>> The case I'm trying to fix has (short)abs((int)short_var). I'd
>thought
>> that if
>> abs(short_var) was undefined because the result couldn't be
>represented
>> then the type
>> conversion from int to short would also be undefined. In fact, it's
>> implementation
>> defined and S4.5 of the GCC manual says that the value is reduced
>until
>> it can be
>> represented. So (short)abs((int)short_var) will produce a value when
>> abs(short_var) is undefined meaning this transformation isn't
>correct.
>> I'll drop this patch.
>
>Maybe we could have an optab and corresponding internal function for an
>
>abs that's always defined.
I'd like to have ABSU_EXPR (or allow unsigned result on ABS_EXPR).
Richard.
>
>Bernd