summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-11-02 15:51:47 +0000
committerSanjay Patel <spatel@rotateright.com>2018-11-02 15:51:47 +0000
commita68096c73e2200ddf57a9d48bd0ed4d55464e841 (patch)
tree83b001d6895093cef7797d0eb067781caf14386b /llvm/lib/Analysis/ValueTracking.cpp
parent1005679ac1ebf77a728ffbff62138e54b41964bb (diff)
downloadbcm5719-llvm-a68096c73e2200ddf57a9d48bd0ed4d55464e841.tar.gz
bcm5719-llvm-a68096c73e2200ddf57a9d48bd0ed4d55464e841.zip
[ValueTracking] allow non-canonical shuffles when computing signbits
This possibility is noted in D53987 for a different case, so we need to adjust the existing code. llvm-svn: 345988
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3cef373f324..89a621576ec 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2511,27 +2511,29 @@ static unsigned ComputeNumSignBitsImpl(const Value *V, unsigned Depth,
// extended, shifted, etc).
return ComputeNumSignBits(U->getOperand(0), Depth + 1, Q);
- case Instruction::ShuffleVector:
+ case Instruction::ShuffleVector: {
// If the shuffle mask contains any undefined elements, that element of the
// result is undefined. Propagating information from a source operand may
// not be correct in that case, so just bail out.
if (cast<ShuffleVectorInst>(U)->getMask()->containsUndefElement())
break;
- assert((!isa<UndefValue>(U->getOperand(0)) ||
- !isa<UndefValue>(U->getOperand(1)))
- && "Should have simplified shuffle with 2 undef inputs");
+ // If everything is undef, we can't say anything. This should be simplified.
+ Value *Op0 = U->getOperand(0), *Op1 = U->getOperand(1);
+ if (isa<UndefValue>(Op0) && isa<UndefValue>(Op1))
+ break;
// Look through shuffle of 1 source vector.
- if (isa<UndefValue>(U->getOperand(0)))
- return ComputeNumSignBits(U->getOperand(1), Depth + 1, Q);
- if (isa<UndefValue>(U->getOperand(1)))
- return ComputeNumSignBits(U->getOperand(0), Depth + 1, Q);
+ if (isa<UndefValue>(Op0))
+ return ComputeNumSignBits(Op1, Depth + 1, Q);
+ if (isa<UndefValue>(Op1))
+ return ComputeNumSignBits(Op0, Depth + 1, Q);
// TODO: We can look through shuffles of 2 sources by computing the minimum
// sign bits for each operand (similar to what we do for binops).
break;
}
+ }
// Finally, if we can prove that the top bits of the result are 0's or 1's,
// use this information.
OpenPOWER on IntegriCloud