[LLVMdev] RFC: Proposal to Remove Poison

Sanjoy Das sanjoy at playingwithpointers.com
Sun Feb 8 14:50:18 PST 2015


> I don't think that program is reasonable.  I also don't think my proposal
> changes the facts on the ground.
>
> consider:
> bool f(int x, int y, bool c) {
>   int add;
>   if (c)
>     add = x + y;
>   return add > x;
> }
>
> Are we permitted to optimize this program to:
> bool f(int x, int y, bool c) {
>   return y > 0;
> }
>
> ?
>
> We do so today.

I'd consider that a bug: f(INT_SMAX, 1, false) should be false IMO --
a phi of poison and undef should be undef, and "undef > INT_SMAX"
should be false.

-- Sanjoy


>
>>
>> (*) 8.5p12 says only, "If an indeterminate value is produced by an
>> evaluation, the behavior is undefined except in the following cases..."
>> [there are some special cases involving values of character type]. There is
>> also a footnote on 3.9.1p6, discussing bool, that says, "Using a bool value
>> in ways described by this International Standard as `undefined,` such as by
>> examining the value of an uninitialized automatic object, might cause it to
>> behave as if it is neither true nor false." But it is not really clear to me
>> whether (c > INT_MAX) is an evaluation having an indeterminate value (except
>> via some circular reasoning).
>>
>>  -Hal
>>
>> --
>> Hal Finkel
>> Assistant Computational Scientist
>> Leadership Computing Facility
>> Argonne National Laboratory
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



More information about the llvm-dev mailing list