Skip to content

Commit 45a148d

Browse files
committed
[ValueTracking] add test for non-canonical shuffle; NFC
llvm-svn: 346025
1 parent 6cef4e5 commit 45a148d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

llvm/unittests/Analysis/ValueTrackingTest.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,29 @@ TEST(ValueTracking, ComputeNumSignBits_Shuffle) {
514514
EXPECT_EQ(ComputeNumSignBits(RVal, M->getDataLayout()), 1u);
515515
}
516516

517+
// FIXME:
518+
// No guarantees for canonical IR in this analysis, so a shuffle element that
519+
// references an undef value means this can't return any extra information.
520+
TEST(ValueTracking, ComputeNumSignBits_Shuffle2) {
521+
StringRef Assembly = "define <2 x i32> @f(<2 x i1> %x) { "
522+
" %sext = sext <2 x i1> %x to <2 x i32> "
523+
" %val = shufflevector <2 x i32> %sext, <2 x i32> undef, <2 x i32> <i32 0, i32 2> "
524+
" ret <2 x i32> %val "
525+
"} ";
526+
527+
LLVMContext Context;
528+
SMDiagnostic Error;
529+
auto M = parseAssemblyString(Assembly, Error, Context);
530+
assert(M && "Bad assembly?");
531+
532+
auto *F = M->getFunction("f");
533+
assert(F && "Bad assembly?");
534+
535+
auto *RVal =
536+
cast<ReturnInst>(F->getEntryBlock().getTerminator())->getOperand(0);
537+
EXPECT_EQ(ComputeNumSignBits(RVal, M->getDataLayout()), 32u);
538+
}
539+
517540
TEST(ValueTracking, ComputeKnownBits) {
518541
StringRef Assembly = "define i32 @f(i32 %a, i32 %b) { "
519542
" %ash = mul i32 %a, 8 "

0 commit comments

Comments
 (0)