================
@@ -5123,14 +5123,26 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
       if (!is_contained({ISD::ADD, ISD::SUB, ISD::MUL}, ISD))
         return InstructionCost::getInvalid();
 
-  if (CtxI && CtxI->getOpcode() == Opcode && CtxI->hasOneUse() &&
+  if (CtxI && CtxI->getOpcode() == Opcode && !CtxI->use_empty() &&
       useNeonVector(Ty)) {
     // The Ands of a bit select are folded into the BSL that the Or becomes.
     Instruction *MainAnd, *OtherAnd;
     Value *A, *B;
-    if (Opcode == Instruction::And &&
+    if (Opcode == Instruction::And && CtxI->hasOneUse() &&
         matchBSL(CtxI->user_back(), MainAnd, OtherAnd, A, B))
       return 0;
+
+    // A Not is folded into the BIC, ORN or BSL of each And/Or using it, unless
+    // that And/Or negates both of its operands.
+    if (match(CtxI, m_Not(m_Value())) &&
+        all_of(CtxI->users(), [&](const User *U) {
----------------
fhahn wrote:

If we want to use those hooks more widely (e.g. inliner 
https://github.com/llvm/llvm-project/pull/232397), it may be a good idea to cap 
the user walks to limit compile-time increase

https://github.com/llvm/llvm-project/pull/232788
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to