[PATCH] D32376: [ValueTracking] Introduce a KnownBits struct to wrap the two APInts for computeKnownBits

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 14:38:23 PDT 2017


craig.topper created this revision.
Herald added a subscriber: mzolotukhin.

This patch introduces a new KnownBits struct that wraps the two APInt used by computeKnownBits. This allows us to treat them as more of a unit.

Initially I've just altered the signatures of computeKnownBits and InstCombine's simplifyDemandedBits to pass a KnownBits reference instead of two separate APInt references. I'll do similar to the SelectionDAG version of computeKnownBits/simplifyDemandedBits as a separate patch.

I've added a constructor that allows initializing both APInts to the same bit width with a starting value of 0. This reduces the repeated pattern of initializing both APInts. Once place default constructed the APInts so I added a default constructor for those cases.

Going forward I would like to add more methods that will work on the pairs. For example trunc, zext, and sext occur on both APInts together in several places. We should probably add a clear method that can be used to clear both pieces. Maybe a method to check for conflicting information. A method to return (Zero|One) so we don't write it out everywhere. Maybe a method for (Zero|One).isAllOnesValue() to determine if all bits are known. I'm sure there are many other methods we can come up with.


https://reviews.llvm.org/D32376

Files:
  include/llvm/Analysis/DemandedBits.h
  include/llvm/Analysis/ValueTracking.h
  lib/Analysis/ConstantFolding.cpp
  lib/Analysis/DemandedBits.cpp
  lib/Analysis/InstructionSimplify.cpp
  lib/Analysis/Lint.cpp
  lib/Analysis/ScalarEvolution.cpp
  lib/Analysis/ValueTracking.cpp
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
  lib/Transforms/InstCombine/InstCombineAddSub.cpp
  lib/Transforms/InstCombine/InstCombineCalls.cpp
  lib/Transforms/InstCombine/InstCombineCasts.cpp
  lib/Transforms/InstCombine/InstCombineCompares.cpp
  lib/Transforms/InstCombine/InstCombineInternal.h
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  lib/Transforms/InstCombine/InstructionCombining.cpp
  lib/Transforms/Scalar/GuardWidening.cpp
  lib/Transforms/Utils/BypassSlowDivision.cpp
  lib/Transforms/Utils/Local.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  lib/Transforms/Utils/SimplifyLibCalls.cpp
  lib/Transforms/Vectorize/LoadStoreVectorizer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32376.96232.patch
Type: text/x-patch
Size: 160504 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170421/d1c447d8/attachment-0001.bin>


More information about the llvm-commits mailing list