[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    RE: Char shifts promoted to int. Why?
From:       "Dave Korn" <dave.korn () artimi ! com>
Date:       2006-12-22 14:44:11
Message-ID: 001301c725d7$a5575970$a501a8c0 () CAM ! ARTIMI ! COM
[Download RAW message or body]

On 21 December 2006 21:54, Ayal Zaks wrote:

>> Something along these lines may be useful to do in the vectorizer when we
>>      get code like this: > ((char)x) = ((char)( ((int)((char)x)) <<
>> ((int)c) ) ) 
>> and don't feel like doing all the unpacking of chars to ints and then
>> packing the ints to chars after the shift. An alternative could be to
>> transform the above pattern to:
>>      char_x1 = 0
>>      char_x2 = char_x << c
>>      char_x = ((int)c < size_of_char) ? char_x2 : char_x1
>> and vectorize that (since we already know how to vectorize selects).
> 
> Alternatively, do
>   char_c2 = (c < size_of_char ? c : 0)
>   char_x2 = char_x << char_c2
> which is like saturating the shift amount.

  You don't really mean zero as the third operand of that ternary operator,
you want size_of_char.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic