[VPlan] Add test with intrinsic without side-effects (NFC).
authorFlorian Hahn <flo@fhahn.com>
Fri, 3 Mar 2023 19:30:30 +0000 (20:30 +0100)
committerFlorian Hahn <flo@fhahn.com>
Fri, 3 Mar 2023 19:30:30 +0000 (20:30 +0100)
Extra test coverage for mayHaveSideEffects for VPWidenCallRecipe.

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

index ff7ee53..4328fe9 100644 (file)
@@ -1140,6 +1140,27 @@ TEST(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
   }
 
   {
+    // Test for a call to a function without side-effects.
+    LLVMContext C;
+    Module M("", C);
+    Function *TheFn = Intrinsic::getDeclaration(&M, Intrinsic::thread_pointer);
+
+    auto *Call = CallInst::Create(TheFn->getFunctionType(), TheFn);
+    VPValue Op1;
+    VPValue Op2;
+    SmallVector<VPValue *, 2> Args;
+    Args.push_back(&Op1);
+    Args.push_back(&Op2);
+    VPWidenCallRecipe Recipe(*Call, make_range(Args.begin(), Args.end()),
+                             false);
+    EXPECT_TRUE(Recipe.mayHaveSideEffects());
+    EXPECT_FALSE(Recipe.mayReadFromMemory());
+    EXPECT_FALSE(Recipe.mayWriteToMemory());
+    EXPECT_FALSE(Recipe.mayReadOrWriteMemory());
+    delete Call;
+  }
+
+  {
     VPValue Op1;
     VPValue Op2;
     InductionDescriptor IndDesc;