[llvm-branch-commits] [llvm] [AArch64][TTI] Cost NEON Nots absorbed by And/Or users as free (PR #232788)
Valeriy Savchenko via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 20 02:43:16 PDT 2026
================
@@ -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) {
----------------
SavchenkoValeriy wrote:
Makes sense, I'll check what caused CT regressions in #232397 and if it is about user traversal, maybe I can make a bounded version of some sort. Let's see
https://github.com/llvm/llvm-project/pull/232788
More information about the llvm-branch-commits
mailing list