[llvm] [SandboxIR] Implement CmpInst, FCmpInst, and ICmpInst (PR #106301)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 17:04:53 PDT 2024
================
@@ -4392,6 +4392,159 @@ define void @foo(i32 %arg) {
EXPECT_EQ(NewPHI->getNumIncomingValues(), PHI->getNumIncomingValues());
}
+static void checkSwapOperands(sandboxir::Context &Ctx,
+ llvm::sandboxir::CmpInst *Cmp,
+ llvm::CmpInst *LLVMCmp) {
+ auto OrigOp0 = Cmp->getOperand(0);
+ auto OrigOp1 = Cmp->getOperand(1);
+ EXPECT_EQ(Ctx.getValue(LLVMCmp->getOperand(0)), OrigOp0);
+ EXPECT_EQ(Ctx.getValue(LLVMCmp->getOperand(1)), OrigOp1);
+ // This checks the dispatch mechanism in CmpInst, as well as
+ // the specific implementations.
+ Cmp->swapOperands();
+ EXPECT_EQ(Ctx.getValue(LLVMCmp->getOperand(1)), OrigOp0);
+ EXPECT_EQ(Ctx.getValue(LLVMCmp->getOperand(0)), OrigOp1);
----------------
Sterling-Augustine wrote:
err, these are the only calls to swap operands. And to ensure that the operands were swapped we need to be sure that the inverse predicate is chosen, as well as switching the operands themselves.
https://github.com/llvm/llvm-project/pull/106301
More information about the llvm-commits
mailing list