[llvm] [AArch64] Sink NOT to be fold into BIC/ORN/EON (PR #176194)

Ricardo Jesus via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 20 08:12:28 PDT 2026


================
@@ -6845,6 +6845,50 @@ bool AArch64TTIImpl::isProfitableToSinkOperands(
     }
     break;
 
+  // Type            |    BIC    |    ORN    |    EON
+  // ----------------+-----------+-----------+-----------
+  // scalar          |    Base   |    Base   |    Base
+  // scalar w/shift  |     -     |     -     |     -
+  // fixed vector    | NEON/Base | NEON/Base | BSL2N/Base
+  // scalable vector |    SVE    |     -     |   BSL2N
+  case Instruction::Xor:
+    // EON only for scalars (possibly expanded fixed vectors)
+    // and vectors using the SVE2/SME BSL2N instruction.
+    if (I->getType()->isVectorTy() && ST->hasNEON() && !ST->hasSVE2() &&
+        !ST->hasSME())
+      break;
+    [[fallthrough]];
+  case Instruction::And:
+  case Instruction::Or:
+    // Even though we could use the SVE2/SME BSL2N instruction,
+    // it might pessimize with an extra MOV depending on register allocation.
+    if (I->getOpcode() == Instruction::Or &&
+        isa<ScalableVectorType>(I->getType()))
+      break;
+    // Shift can be fold into scalar AND/ORR/EOR,
+    // but not the non-negated operand of BIC/ORN/EON.
+    if (!(I->getType()->isVectorTy() && ST->hasNEON()) &&
----------------
rj-jesus wrote:

I see, thanks, I think this makes sense.

https://github.com/llvm/llvm-project/pull/176194


More information about the llvm-commits mailing list