[llvm] [TRE] Add tests for intrinsic accumulators (PR #74226)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 3 01:16:18 PST 2023
================
@@ -369,12 +369,25 @@ static bool canTransformAccumulatorRecursion(Instruction *I, CallInst *CI) {
if (!I->isAssociative() || !I->isCommutative())
return false;
- assert(I->getNumOperands() == 2 &&
- "Associative/commutative operations should have 2 args!");
+ Value *LHS;
+ Value *RHS;
+ if (I->isBinaryOp()) {
+ LHS = I->getOperand(0);
+ RHS = I->getOperand(1);
+ } else if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
+ // Accumulators must have an identity.
+ if (!ConstantExpr::getIntrinsicIdentity(II->getIntrinsicID(), I->getType()))
+ return false;
+ // 0'th operand is the intrinsic function
----------------
nikic wrote:
I'm quite confused here. The callee is the last operand, not the first one. How does this code work?
https://github.com/llvm/llvm-project/pull/74226
More information about the llvm-commits
mailing list