[llvm-dev] [poison] is select-of-select to logic+select allowed?
Nuno Lopes via llvm-dev
llvm-dev at lists.llvm.org
Wed May 24 10:55:23 PDT 2017
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170524/502d4e71/attachment.html>
More information about the llvm-dev
mailing list