[llvm-dev] [poison] re: is select-of-select to logic+select allowed ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[llvm-dev] [poison] re: is select-of-select to logic+select allowed ?

George Karpenkov via llvm-dev
Nuno,
Sanjoy,
            Can you provide some actual C source code examples that show how
End-to-end-miscompilations have resulted from the presence of “UB” in
Select statements ?

Thanks,
Peter Lawrence.


PS, IMHO “plain asci” isn’t that hard !


Summary table of what each transformation allows for 
        %z = select %c, %x, %y
Each column is a different alternative of semantics for select:


1.   UB if %c poison + conditional poison

2.   UB if %c poison + poison if either %x/%y poison

3.   Conditional poison + non-det choice if %c poison

4.   Conditional poison + poison if %c poison**

5.   Poison if any of %c/%x/%y are poison


            option    1   2   3   4   5

SimplifyCFG           ✓   .   ✓   ✓   .   

Select->control-flow  ✓   ✓   .   .   .

Select->arithmetic    .   ✓   .   .   .

partially             ✓   .   .   .   .

Select removal        ✓   ✓   ✓   ✓   ✓

Select hoist          ✓   ✓   ✓   .   .

Easy movement         .   .   ✓   ✓   ✓


IMHO, the 3rd and 4th options are the ones that work best.  Instructions with UB are usually a pain (for e.g. hoisting out o
f loops).






On May 24, 2017, at 11:51 AM, via llvm-dev <[hidden email]> wrote:

Message: 3
Date: Wed, 24 May 2017 18:55:23 +0100
From: Nuno Lopes via llvm-dev <[hidden email]>
To: "'David Menendez'" <[hidden email]>
Cc: 'llvm-dev' <[hidden email]>, 'John Regehr'
<[hidden email]>
Subject: Re: [llvm-dev] [poison] is select-of-select to logic+select
allowed?
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="utf-8"

Thanks David for pointing out a mistake in the table! I implemented most of the semantics shown in the table in Alive to test these things, but the bug still slipped through, sorry..



I’ve updated the table:



Summary table of what each transformation allows for %z = select %c, %x, %y. Each column is a different alternative of semantics for select:






UB if %c poison

+ conditional poison

UB if %c poison + poison if either
%x/%y poison

Conditional poison

+ non-det choice if %c poison

Conditional poison + poison if %c poison**

Poison if any of
%c/%x/%y are poison


SimplifyCFG












Select->control-flow












Select->arithmetic







partially 




Select removal





 






Select hoist












Easy movement















IMHO, the 3rd and 4th options are the ones that work best.  Instructions with UB are usually a pain (for e.g. hoisting out of loops).



An advantage of the 4th option is that can partially do select->arithmetic, while the 3rd can’t.  For example, this is valid with the 4th option:

%13 = mul nuw i2 %0, -1

%14 = srem i2 %13, -1

%15 = select i1 %1, i2 1, i2 %14

 =>

%15 = zext i1 %1 to i2





The 4th option, however, can’t do the select->and/or transformations (neither the 3rd can).



That said, I’m inclined to choose the 4th option (marked with ** in the table).  That’s the one that the online version of Alive implements BTW.



Nuno


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] [poison] re: is select-of-select to logic+select allowed ?

George Karpenkov via llvm-dev
On 7 June 2017 at 04:25, Peter Lawrence via llvm-dev
<[hidden email]> wrote:
> Nuno,
> Sanjoy,
>             Can you provide some actual C source code examples that show how
> End-to-end-miscompilations have resulted from the presence of “UB” in
> Select statements ?

We hit an example of this recently. See
https://bugs.llvm.org/show_bug.cgi?id=34133
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] [poison] re: is select-of-select to logic+select allowed ?

George Karpenkov via llvm-dev
Dan,
        Many thanks for pointing this out,
Will look into it when back from vacation in Sept.
Peter Lawrence.


> On Aug 10, 2017, at 1:59 AM, Dan Liew <[hidden email]> wrote:
>
> On 7 June 2017 at 04:25, Peter Lawrence via llvm-dev
> <[hidden email]> wrote:
>> Nuno,
>> Sanjoy,
>>            Can you provide some actual C source code examples that show how
>> End-to-end-miscompilations have resulted from the presence of “UB” in
>> Select statements ?
>
> We hit an example of this recently. See
> https://bugs.llvm.org/show_bug.cgi?id=34133

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Loading...