Skip to content

Commit 2578122

Browse files
authored
[instcombine] Delete dead transform for reverse of binop (#143967)
We canonicalize reverse to after a binop in foldVectorBinop, and simplify reverse pairs in InstSimplify, so these elimination transforms are redundant.
1 parent 402c376 commit 2578122

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,32 +3555,13 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
35553555
break;
35563556
}
35573557
case Intrinsic::vector_reverse: {
3558-
Value *BO0, *BO1, *X, *Y;
35593558
Value *Vec = II->getArgOperand(0);
3560-
if (match(Vec, m_OneUse(m_BinOp(m_Value(BO0), m_Value(BO1))))) {
3561-
auto *OldBinOp = cast<BinaryOperator>(Vec);
3562-
if (match(BO0, m_VecReverse(m_Value(X)))) {
3563-
// rev(binop rev(X), rev(Y)) --> binop X, Y
3564-
if (match(BO1, m_VecReverse(m_Value(Y))))
3565-
return replaceInstUsesWith(CI, BinaryOperator::CreateWithCopiedFlags(
3566-
OldBinOp->getOpcode(), X, Y,
3567-
OldBinOp, OldBinOp->getName(),
3568-
II->getIterator()));
3569-
// rev(binop rev(X), BO1Splat) --> binop X, BO1Splat
3570-
if (isSplatValue(BO1))
3571-
return replaceInstUsesWith(CI, BinaryOperator::CreateWithCopiedFlags(
3572-
OldBinOp->getOpcode(), X, BO1,
3573-
OldBinOp, OldBinOp->getName(),
3574-
II->getIterator()));
3575-
}
3576-
// rev(binop BO0Splat, rev(Y)) --> binop BO0Splat, Y
3577-
if (match(BO1, m_VecReverse(m_Value(Y))) && isSplatValue(BO0))
3578-
return replaceInstUsesWith(CI,
3579-
BinaryOperator::CreateWithCopiedFlags(
3580-
OldBinOp->getOpcode(), BO0, Y, OldBinOp,
3581-
OldBinOp->getName(), II->getIterator()));
3582-
}
3559+
// Note: We canonicalize reverse after binops, so we don't need a
3560+
// corresponding binop case here. TODO: Consider canonicalizing
3561+
// reverse after fneg?
3562+
35833563
// rev(unop rev(X)) --> unop X
3564+
Value *X;
35843565
if (match(Vec, m_OneUse(m_UnOp(m_VecReverse(m_Value(X)))))) {
35853566
auto *OldUnOp = cast<UnaryOperator>(Vec);
35863567
auto *NewUnOp = UnaryOperator::CreateWithCopiedFlags(

0 commit comments

Comments
 (0)