Remove dead code from Linalg vectorization to fix GCC warning (NFC)

This commit is contained in:
Mehdi Amini 2021-02-04 17:37:25 +00:00
parent 953086ddbb
commit 215441fcb7
1 changed files with 0 additions and 48 deletions

View File

@ -38,20 +38,6 @@ using llvm::dbgs;
#define DEBUG_TYPE "linalg-vectorization"
/// Return true if the use-def chain from `v` to `from` consists of 0 or more
/// unary single-operand operations.
// TODO: relax to multi-operands with constants, which are technically unary ops
// as needed (e.g. add5).
static bool isChainOfUnaryOpsFrom(Value v, Value from) {
while (v != from) {
Operation *op = v.getDefiningOp();
if (!op || op->getNumOperands() != 1)
return false;
v = op->getOperand(0);
};
return true;
}
/// Return the unique instance of OpType in `block` if it is indeed unique.
/// Return null if none or more than 1 instances exist.
template <typename OpType>
@ -68,40 +54,6 @@ static OpType getSingleOpOfType(Block &block) {
return res;
}
/// Detect whether res is any permutation of `u5(u1(c) + u2(u3(a) * u4(b)))`
/// on the field (AddOpType, MulOpType), where u1, u2, u3, u4 and u5 represent
/// unary operations that may change the type.
template <typename AddOpType, typename MulOpType>
static bool isAddMul(Block &block) {
if (block.getNumArguments() != 3)
return false;
Operation *yieldOp = block.getTerminator();
if (yieldOp->getNumOperands() != 1)
return false;
LLVM_DEBUG(dbgs() << "\n[" DEBUG_TYPE "]: isAddMul: "; block.dump());
AddOpType addOp = getSingleOpOfType<AddOpType>(block);
MulOpType mulOp = getSingleOpOfType<MulOpType>(block);
if (!addOp || !mulOp)
return false;
Value argA = block.getArgument(0), argB = block.getArgument(1);
Value a = mulOp->getOperand(0), b = mulOp->getOperand(1);
Value mul = mulOp->getResult(0);
Value argC = block.getArgument(2);
Value c1 = addOp->getOperand(0), c2 = addOp->getOperand(1);
Value add = addOp->getResult(0);
Value res = yieldOp->getOperand(0);
// Result traces back to add.
auto un = isChainOfUnaryOpsFrom;
bool success = un(res, add);
// One of the operands of add traces back to argC, the other to the mul.
success |= (un(c1, argC) && un(c2, mul)) || ((un(c1, mul)) && un(c2, argC));
// One of the operands of mul traces back to argA, the other to argB.
success |= (un(a, argA) && un(b, argB)) || ((un(a, argB)) && un(b, argA));
return success;
}
/// Helper data structure to represent the result of vectorization.
/// In certain specific cases, like terminators, we do not want to propagate/
enum VectorizationStatus {