[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
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index ccae9d1..f7d715c 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -494,6 +494,26 @@
EXPECT_EQ(ComputeNumSignBits(RVal, M->getDataLayout()), 1u);
}
+// No guarantees for canonical IR in this analysis, so this just bails out.
+TEST(ValueTracking, ComputeNumSignBits_Shuffle) {
+ StringRef Assembly = "define <2 x i32> @f() { "
+ " %val = shufflevector <2 x i32> undef, <2 x i32> undef, <2 x i32> <i32 0, i32 0> "
+ " 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()), 1u);
+}
+
TEST(ValueTracking, ComputeKnownBits) {
StringRef Assembly = "define i32 @f(i32 %a, i32 %b) { "
" %ash = mul i32 %a, 8 "