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

Nick Lewycky nicholas at mxc.ca
Thu Jun 18 00:17:47 PDT 2009


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!

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: jump-threading.patch
Type: text/x-patch
Size: 6183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090618/f428eef4/attachment.bin>


More information about the llvm-commits mailing list