[PATCH] D16108: [ValueTracking] Understand more select patterns in ComputeKnownBits

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 04:31:05 PST 2016


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

Some patterns of select+compare allow us to know exactly the value of the uppermost bits in the select result. For example:

  %b = icmp ugt i32 %a, 5
  %c = select i1 %b, i32 2, i32 %a

Here we know that %c is bounded by 5, and therefore KnownZero = ~APInt(5).getActiveBits() = ~7.

There are several such patterns, and this patch attempts to understand a reasonable subset of them - namely when the base values are the same (as above), and when they are related by a simple (add nsw), for example (add nsw %a, 4) and %a.

Repository:
  rL LLVM

http://reviews.llvm.org/D16108

Files:
  lib/Analysis/ValueTracking.cpp
  test/Analysis/ValueTracking/select-maxbits.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16108.44618.patch
Type: text/x-patch
Size: 3634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160112/b7bcf105/attachment.bin>


More information about the llvm-commits mailing list