[llvm-commits] proposed patch: shift when shift amount >= bit width
Chris Lattner
clattner at apple.com
Wed Jun 13 11:50:52 PDT 2007
On Jun 13, 2007, at 11:34 AM, Lauro Ramos Venancio wrote:
>>
>> This is not enough to make a compiler handle shifts by greater
>> than the
>> word size consistently; in both gcc and llvm-gcc, for example, the
>> result of
>>
>> int y=32;
>> x>>y
>>
>> depends on optimization level.
>
> I know. On x86, the result of
> int n = 32;
> 1<<n
>
> is 1 with "gcc -O0" and 0 with "gcc -O3". But some important programs
> (like ffmpeg) use these shifts expecting the gcc behavior. The ffmpeg,
> for example, works well with "gcc -O0" and "gcc -O3". So, for
> compatibility purpose, I think we should implement the gcc behavior
> and do not create another behavior.
I don't think this is appropriate Lauro. The program needs to be
fixed, it's not just a codegen or optimizer issue, everything in the
compiler assumes that these shifts are undefined. Programs cannot
reliably expect a compiler to do the right thing here, and your patch
isn't a fix.
-Chris
More information about the llvm-commits
mailing list