This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PR tree-optimization/64946] Push integer type conversion to ABS_EXPR argument when possible.


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]