[PATCH] D18905: [ValueTracking] Improve isImpliedCondition for conditions with matching but swapped operands.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 12:34:20 PDT 2016


mcrosier created this revision.
mcrosier added reviewers: sanjoy, reames.
mcrosier added a subscriber: llvm-commits.
mcrosier set the repository for this revision to rL LLVM.

This patch improves SimplifyCFG to catch things like:

 if (a < b) {
   if (b < a) <- known to be false
     unreachable;
 }

and

 if (a > b) {
   if (b < a) { <- always true; remove control flow
     always reachable;
   }
 }

The later case is generally captured when the compares are canonicalized, but in my testing I found that there are cases in the wild where compares aren't always in canonical form.  I do plan on addressing the FIXME in jump threading, but I wanted to get this patch approved first.

Please take a look,
  Chad

Repository:
  rL LLVM

http://reviews.llvm.org/D18905

Files:
  include/llvm/Analysis/ValueTracking.h
  lib/Analysis/InstructionSimplify.cpp
  lib/Analysis/ValueTracking.cpp
  lib/Transforms/Scalar/JumpThreading.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Transforms/SimplifyCFG/implied-cond-swapped.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18905.53063.patch
Type: text/x-patch
Size: 9863 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160408/f1d91c44/attachment.bin>


More information about the llvm-commits mailing list