[PATCH] D131838: [ValueTracking] computeKnownBits - attempt to use a branch condition feeding a phi to improve known bits range

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 13 06:57:20 PDT 2022


RKSimon created this revision.
RKSimon added reviewers: spatel, nikic, reames, fhahn, xbolva00.
Herald added subscribers: foad, hiraditya.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added a project: LLVM.

If computeKnownBits encounters a phi node, and we fail to determine any known bits through direct analysis, see if the incoming value is part of a branch condition feeding the phi.

Handle cases where icmp(IncomingValue PRED Constant) is driving a branch instruction feeding that phi node - at the moment this only handles EQ/ULT/ULE predicate cases as they are the most straightforward to handle and most likely for branch-loop 'max upper bound' cases - we can extend this if/when necessary.

I investigated a more general icmp(LHS PRED RHS) KnownBits system, but the hard limits we put on value tracking depth through phi nodes meant that we were mainly catching constants anyhow.

Fixes issue #37628


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131838

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstCombine/known-phi-br.ll
  llvm/test/Transforms/PhaseOrdering/X86/pr38280.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131838.452421.patch
Type: text/x-patch
Size: 29448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220813/c92e2711/attachment.bin>


More information about the llvm-commits mailing list