[PATCH] D33262: [JumpThreading] Teach jump threading how to analyze (and (cmp A, C1), (cmp A, C2)) after InstCombine has turned it into (cmp (add A, C3), C4)

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 15:45:08 PDT 2017


craig.topper created this revision.

Currently JumpThreading can use LazyValueInfo to analyze an 'and' or 'or' of compare if the compare is fed by a livein of a basic block. This can be used to to prove the condition can't be met for some predecessor and the jump from that predecessor can be moved to the false path of the condition.

But if the compare is something that InstCombine turns into an add and a single compare, it can't be analyzed because the livein is now an input to the add and not the compare.

This patch adds a new getPredicateOnEdgeAfterAdd entry point to LazyValueInfo that allows for an adjustment to be made to the livein's range before doing the compare predicate check. JumpThreading is then taught to use this entry point if it can see that there is an add of a livein with a constant that is used by a compare.

I'm not sure this is the right division of labor between the two passes so I'm open to other opinions on where the line should be.


https://reviews.llvm.org/D33262

Files:
  include/llvm/Analysis/LazyValueInfo.h
  lib/Analysis/LazyValueInfo.cpp
  lib/Transforms/Scalar/JumpThreading.cpp
  test/Transforms/JumpThreading/range-compare.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33262.99220.patch
Type: text/x-patch
Size: 8593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170516/36a076f4/attachment.bin>


More information about the llvm-commits mailing list