@@ -537,8 +537,7 @@ static bool isSplat(ArrayRef<Value *> VL) {
537537/// \param I The instruction to check for commutativity
538538/// \param ValWithUses The value whose uses are analyzed for special
539539/// patterns
540- static bool isCommutative(Instruction *I, Value *ValWithUses,
541- bool IsCopyable = false) {
540+ static bool isCommutative(Instruction *I, Value *ValWithUses) {
542541 if (auto *Cmp = dyn_cast<CmpInst>(I))
543542 return Cmp->isCommutative();
544543 if (auto *BO = dyn_cast<BinaryOperator>(I))
@@ -547,7 +546,7 @@ static bool isCommutative(Instruction *I, Value *ValWithUses,
547546 !ValWithUses->hasNUsesOrMore(UsesLimit) &&
548547 all_of(
549548 ValWithUses->uses(),
550- [& ](const Use &U) {
549+ [](const Use &U) {
551550 // Commutative, if icmp eq/ne sub, 0
552551 CmpPredicate Pred;
553552 if (match(U.getUser(),
@@ -556,11 +555,10 @@ static bool isCommutative(Instruction *I, Value *ValWithUses,
556555 return true;
557556 // Commutative, if abs(sub nsw, true) or abs(sub, false).
558557 ConstantInt *Flag;
559- auto *I = dyn_cast<BinaryOperator>(U.get());
560558 return match(U.getUser(),
561559 m_Intrinsic<Intrinsic::abs>(
562560 m_Specific(U.get()), m_ConstantInt(Flag))) &&
563- ((!IsCopyable && I && !I ->hasNoSignedWrap() ) ||
561+ (!cast<Instruction>(U.get()) ->hasNoSignedWrap() ||
564562 Flag->isOne());
565563 })) ||
566564 (BO->getOpcode() == Instruction::FSub &&
@@ -3166,8 +3164,7 @@ class BoUpSLP {
31663164 bool IsInverseOperation = false;
31673165 if (S.isCopyableElement(VL[Lane])) {
31683166 // The value is a copyable element.
3169- IsInverseOperation =
3170- !isCommutative(MainOp, VL[Lane], /*IsCopyable=*/true);
3167+ IsInverseOperation = !isCommutative(MainOp, VL[Lane]);
31713168 } else {
31723169 assert(I && "Expected instruction");
31733170 auto [SelectedOp, Ops] = convertTo(I, S);
0 commit comments