summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/VectorUtils.cpp
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2016-05-09 14:32:30 +0000
committerJames Molloy <james.molloy@arm.com>2016-05-09 14:32:30 +0000
commit5c20e27b7fcc8fad80f9c209f4d49c6995bd5cc2 (patch)
tree06da14665151849d3a6a04a8b2bc466cc81723d2 /llvm/lib/Analysis/VectorUtils.cpp
parentb6aed5f44123d8fcd651e4225ea62c8b8d34c255 (diff)
downloadbcm5719-llvm-5c20e27b7fcc8fad80f9c209f4d49c6995bd5cc2.tar.gz
bcm5719-llvm-5c20e27b7fcc8fad80f9c209f4d49c6995bd5cc2.zip
[VectorUtils] Query number of sign bits to allow more truncations
When deciding if a vector calculation can be done in a smaller bitwidth, use sign bit information from ValueTracking to add more information and allow more truncations. llvm-svn: 268921
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r--llvm/lib/Analysis/VectorUtils.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 23a0de856bc..2c03f1a05ce 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -320,6 +320,9 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
SmallPtrSet<Instruction *, 4> InstructionSet;
MapVector<Instruction *, uint64_t> MinBWs;
+ assert(Blocks.size() > 0 && "Must have at least one block!");
+ const DataLayout &DL = Blocks[0]->getModule()->getDataLayout();
+
// Determine the roots. We work bottom-up, from truncs or icmps.
bool SeenExtFromIllegalType = false;
for (auto *BB : Blocks)
@@ -363,12 +366,19 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
// If we encounter a type that is larger than 64 bits, we can't represent
// it so bail out.
- if (DB.getDemandedBits(I).getBitWidth() > 64)
+ APInt NeededBits = DB.getDemandedBits(I);
+ unsigned BW = NeededBits.getBitWidth();
+ if (BW > 64)
return MapVector<Instruction *, uint64_t>();
- uint64_t V = DB.getDemandedBits(I).getZExtValue();
- DBits[Leader] |= V;
- DBits[I] = V;
+ auto NSB = ComputeNumSignBits(I, DL);
+
+ // Query demanded bits for the bits required by the instruction. Remove
+ // any bits that are equal to the sign bit, because we can truncate the
+ // instruction without changing their value.
+ NeededBits &= APInt::getLowBitsSet(BW, BW - NSB);
+ DBits[Leader] |= NeededBits.getZExtValue();
+ DBits[I] |= NeededBits.getZExtValue();
// Casts, loads and instructions outside of our range terminate a chain
// successfully.
OpenPOWER on IntegriCloud