[llvm-commits] teach jump-threading to handle br(icmp against non-constants)

Chris Lattner clattner at apple.com
Thu Jun 18 21:34:15 PDT 2009


On Jun 18, 2009, at 12:17 AM, Nick Lewycky wrote:
> The attached patch teaches jump threading to handle the case where a  
> PHI node is compared against an element inside the PHI node.
> Please review!

The patch looks great, please apply with these changes:

1. Please rename resultOfComparison to something like  
GetResultOfComparison.
2. Please add a doxygen comment describing what the operands are and  
what it does.

Thanks for working on this.  If you're interested, there are a ton of  
similar improvements that we can make to jump threading.

-Chris

>
> There are still a couple of related optimizations this is missing:
>  1. we could create FCmpInst::isFalseWhenEqual and use that to  
> handle some of the equivalent cases for float. Note that "true when  
> equal" is not well defined for floats thanks to NaNs, but false  
> should be fine.
>  2. we could handle this:
>
>       jt:
>         %x = phi i8 [%a, %bb1], [0, %bb2]
>         %A = icmp ugt i8 %x, %b
>         br i1 %A, label %rt, label %rf
>
>     if we realized that "icmp ult i8 0, %b" is never true. There's a  
> small battery of related tests.
>
> If someone does implement the above extensions, it would probably  
> make sense to factor out "resultOfComparison" and put it somewhere  
> more generally useful. Instcombine does these too, for example.
>
> Nick
>
> <jump-threading.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list