aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/VectorUtils.cpp
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2016-03-30 10:11:43 +0000
committerJames Molloy <james.molloy@arm.com>2016-03-30 10:11:43 +0000
commit8e46cd05a17c0499f744a85f8ef905cafb47eb3e (patch)
tree14d712aa667803901874fd82784d9504e4bd2fdc /llvm/lib/Analysis/VectorUtils.cpp
parentb780c44eeca9a1724c53adb82501587a1fcd9750 (diff)
downloadllvm-8e46cd05a17c0499f744a85f8ef905cafb47eb3e.zip
llvm-8e46cd05a17c0499f744a85f8ef905cafb47eb3e.tar.gz
llvm-8e46cd05a17c0499f744a85f8ef905cafb47eb3e.tar.bz2
[VectorUtils] Don't try and truncate PHIs to a smaller bitwidth
We already try not to truncate PHIs in computeMinimalBitwidths. LoopVectorize can't handle it and we really don't need to, because both induction and reduction PHIs are truncated by other means. However, we weren't bailing out in all the places we should have, and we ended up by returning a PHI to be truncated, which has caused PR27018. This fixes PR17018. llvm-svn: 264852
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r--llvm/lib/Analysis/VectorUtils.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index d9b1354..2881645 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -499,6 +499,7 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
uint64_t V = DB.getDemandedBits(I).getZExtValue();
DBits[Leader] |= V;
+ DBits[I] = V;
// Casts, loads and instructions outside of our range terminate a chain
// successfully.
@@ -549,6 +550,20 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
// Round up to a power of 2
if (!isPowerOf2_64((uint64_t)MinBW))
MinBW = NextPowerOf2(MinBW);
+
+ // We don't modify the types of PHIs. Reductions will already have been
+ // truncated if possible, and inductions' sizes will have been chosen by
+ // indvars.
+ // If we are required to shrink a PHI, abandon this entire equivalence class.
+ bool Abort = false;
+ for (auto MI = ECs.member_begin(I), ME = ECs.member_end(); MI != ME; ++MI)
+ if (isa<PHINode>(*MI) && MinBW < (*MI)->getType()->getScalarSizeInBits()) {
+ Abort = true;
+ break;
+ }
+ if (Abort)
+ continue;
+
for (auto MI = ECs.member_begin(I), ME = ECs.member_end(); MI != ME; ++MI) {
if (!isa<Instruction>(*MI))
continue;