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 | a68096c73e2200ddf57a9d48bd0ed4d55464e841 (patch) | |
tree | 83b001d6895093cef7797d0eb067781caf14386b /llvm/unittests/Analysis/ValueTrackingTest.cpp | |
parent | 1005679ac1ebf77a728ffbff62138e54b41964bb (diff) | |
download | bcm5719-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/unittests/Analysis/ValueTrackingTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/ValueTrackingTest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp index ccae9d19ebb..f7d715c6447 100644 --- a/llvm/unittests/Analysis/ValueTrackingTest.cpp +++ b/llvm/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 " |