[PATCH] D16109: [ValueTracking] Improve known bits detection for PHI recurrences

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 05:04:59 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.

Proving many facts about PHIs in ValueTracking is difficult due to its context-free nature (no caching). However, it is possible to prove that a PHI is non-negative (MSB is known zero) in many real-world situations.

Often, induction variables are very simple. We already have some support for looking at trivial induction variables (simple adds for example) in order to prove low-order bits are always zero due to stride.

This patch introduces more analysis for PHIs. Specifically, if a two-entry PHI has a non-negative constant integer in one operand it will try and trace the other operand through certain instructions until it hopefully finds the PHI again.

The set of instructions that will be recursed through is deliberately small - add, mul and select. On top of this small set, we will only ever follow a linear chain (an add/mul with a non-negative constant integer as the RHS operand). Because we only ever follow a linear chain of simple instructions the search space can never expand too much which also allows us to set a non-tiny search limit.

Repository:
  rL LLVM

http://reviews.llvm.org/D16109

Files:
  lib/Analysis/ValueTracking.cpp
  test/Analysis/ValueTracking/knownbits-phi.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16109.44620.patch
Type: text/x-patch
Size: 4883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160112/3c80641b/attachment.bin>


More information about the llvm-commits mailing list