[llvm] r300849 - In SimplifyDemandedUseBits, use computeKnownBits directly to handle Constants
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 20 09:14:58 PDT 2017
Author: ctopper
Date: Thu Apr 20 11:14:58 2017
New Revision: 300849
URL: http://llvm.org/viewvc/llvm-project?rev=300849&view=rev
Log:
In SimplifyDemandedUseBits, use computeKnownBits directly to handle Constants
Currently we don't explicitly process ConstantDataSequential, ConstantAggregateZero, or ConstantVector, or Undef before applying the Depth limit. Instead they occur after the depth check in the non-instruction path.
For the constant types that we do handle, the code is replicated from computeKnownBits.
This patch fixes the missing constant handling and the reduces the amount of code by just using computeKnownBits directly for any type of Constant.
Differential Revision: https://reviews.llvm.org/D32123
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=300849&r1=300848&r2=300849&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Thu Apr 20 11:14:58 2017
@@ -117,27 +117,16 @@ Value *InstCombiner::SimplifyDemandedUse
KnownOne.getBitWidth() == BitWidth &&
"Value *V, DemandedMask, KnownZero and KnownOne "
"must have same BitWidth");
- const APInt *C;
- if (match(V, m_APInt(C))) {
- // We know all of the bits for a scalar constant or a splat vector constant!
- KnownOne = *C;
- KnownZero = ~KnownOne;
- return nullptr;
- }
- if (isa<ConstantPointerNull>(V)) {
- // We know all of the bits for a constant!
- KnownOne.clearAllBits();
- KnownZero.setAllBits();
+
+ if (isa<Constant>(V)) {
+ computeKnownBits(V, KnownZero, KnownOne, Depth, CxtI);
return nullptr;
}
KnownZero.clearAllBits();
KnownOne.clearAllBits();
- if (DemandedMask == 0) { // Not demanding any bits from V.
- if (isa<UndefValue>(V))
- return nullptr;
+ if (DemandedMask == 0) // Not demanding any bits from V.
return UndefValue::get(VTy);
- }
if (Depth == 6) // Limit search depth.
return nullptr;
More information about the llvm-commits
mailing list