aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-11-02 18:14:24 +0000
committerSanjay Patel <spatel@rotateright.com>2018-11-02 18:14:24 +0000
commit6892afb33a7162281ee8727071649133e905df8d (patch)
tree2cf152ae0f47e5a6443b32c56302a0907728bd2f /unittests
parent437cbaffffc74a5bb3bac31e7a649a144e14fdd4 (diff)
[ValueTracking] add test for non-canonical shuffle; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346025 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Analysis/ValueTrackingTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/unittests/Analysis/ValueTrackingTest.cpp b/unittests/Analysis/ValueTrackingTest.cpp
index f7d715c6447..e66d8f77fd4 100644
--- a/unittests/Analysis/ValueTrackingTest.cpp
+++ b/unittests/Analysis/ValueTrackingTest.cpp
@@ -514,6 +514,29 @@ TEST(ValueTracking, ComputeNumSignBits_Shuffle) {
EXPECT_EQ(ComputeNumSignBits(RVal, M->getDataLayout()), 1u);
}
+// FIXME:
+// No guarantees for canonical IR in this analysis, so a shuffle element that
+// references an undef value means this can't return any extra information.
+TEST(ValueTracking, ComputeNumSignBits_Shuffle2) {
+ StringRef Assembly = "define <2 x i32> @f(<2 x i1> %x) { "
+ " %sext = sext <2 x i1> %x to <2 x i32> "
+ " %val = shufflevector <2 x i32> %sext, <2 x i32> undef, <2 x i32> <i32 0, i32 2> "
+ " ret <2 x i32> %val "
+ "} ";
+
+ LLVMContext Context;
+ SMDiagnostic Error;
+ auto M = parseAssemblyString(Assembly, Error, Context);
+ assert(M && "Bad assembly?");
+
+ auto *F = M->getFunction("f");
+ assert(F && "Bad assembly?");
+
+ auto *RVal =
+ cast<ReturnInst>(F->getEntryBlock().getTerminator())->getOperand(0);
+ EXPECT_EQ(ComputeNumSignBits(RVal, M->getDataLayout()), 32u);
+}
+
TEST(ValueTracking, ComputeKnownBits) {
StringRef Assembly = "define i32 @f(i32 %a, i32 %b) { "
" %ash = mul i32 %a, 8 "