diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-11-02 15:51:47 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-11-02 15:51:47 +0000 |
commit | 6709348e9f65d8fbead4f2d25f9cc174edc075d9 (patch) | |
tree | 3649ab45f023582fac085c6ce90208e7ec22e4ab /unittests | |
parent | 1b82386f5eb67c1a5e54c70aff291c01c4e028da (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345988 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Analysis/ValueTrackingTest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/unittests/Analysis/ValueTrackingTest.cpp b/unittests/Analysis/ValueTrackingTest.cpp index ccae9d19ebb..f7d715c6447 100644 --- a/unittests/Analysis/ValueTrackingTest.cpp +++ b/unittests/Analysis/ValueTrackingTest.cpp @@ -494,6 +494,26 @@ TEST(ValueTracking, ComputeNumSignBits_PR32045) { 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 " |