llvm.org GIT mirror llvm / 6892afb
[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 Sanjay Patel 10 months ago
1 changed file(s) with 23 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
513513 EXPECT_EQ(ComputeNumSignBits(RVal, M->getDataLayout()), 1u);
514514 }
515515
516 // FIXME:
517 // No guarantees for canonical IR in this analysis, so a shuffle element that
518 // references an undef value means this can't return any extra information.
519 TEST(ValueTracking, ComputeNumSignBits_Shuffle2) {
520 StringRef Assembly = "define <2 x i32> @f(<2 x i1> %x) { "
521 " %sext = sext <2 x i1> %x to <2 x i32> "
522 " %val = shufflevector <2 x i32> %sext, <2 x i32> undef, <2 x i32> "
523 " ret <2 x i32> %val "
524 "} ";
525
526 LLVMContext Context;
527 SMDiagnostic Error;
528 auto M = parseAssemblyString(Assembly, Error, Context);
529 assert(M && "Bad assembly?");
530
531 auto *F = M->getFunction("f");
532 assert(F && "Bad assembly?");
533
534 auto *RVal =
535 cast(F->getEntryBlock().getTerminator())->getOperand(0);
536 EXPECT_EQ(ComputeNumSignBits(RVal, M->getDataLayout()), 32u);
537 }
538
516539 TEST(ValueTracking, ComputeKnownBits) {
517540 StringRef Assembly = "define i32 @f(i32 %a, i32 %b) { "
518541 " %ash = mul i32 %a, 8 "