[llvm] [SandboxIR] Functions to find vectorizor-relevant properties (PR #109221)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 14:49:38 PDT 2024


================
@@ -947,6 +949,38 @@ define i32 @foo(i32 %arg0, i32 %arg1) {
   EXPECT_EQ(Glob0->getOperand(0), Glob1);
 }
 
+TEST_F(SandboxIRTest, GetExpected) {
+  parseIR(C, R"IR(
+define float @foo(float %v, ptr %ptr) {
+  %add = fadd float %v, %v
+  store float %v, ptr %ptr
+  ret float %v
+}
+)IR");
+  llvm::Function &LLVMF = *M->getFunction("foo");
+  sandboxir::Context Ctx(C);
+  llvm::BasicBlock *LLVMBB = &*LLVMF.begin();
+
+  Ctx.createFunction(&LLVMF);
+  auto *BB = cast<sandboxir::BasicBlock>(Ctx.getValue(LLVMBB));
+  auto It = BB->begin();
+  auto Add = cast<sandboxir::Instruction>(&*It++);
+  auto *S0 = cast<sandboxir::Instruction>(&*It++);
+  auto *Ret = cast<sandboxir::Instruction>(&*It++);
+  // Instruction.getExpectedValue
+  EXPECT_EQ(Add->getExpectedValue(), Add);
+  EXPECT_EQ(S0->getExpectedValue(),
+            cast<sandboxir::StoreInst>(S0)->getValueOperand());
+  EXPECT_EQ(Ret->getExpectedValue(),
+            cast<sandboxir::ReturnInst>(Ret)->getReturnValue());
----------------
Sterling-Augustine wrote:

Added

https://github.com/llvm/llvm-project/pull/109221


More information about the llvm-commits mailing list