[llvm] [AArch64][SVE2] Generate SVE2 BSL instruction in LLVM for bit-twiddling. (PR #83514)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 09:15:13 PDT 2024


================
@@ -17594,16 +17594,14 @@ static SDValue tryCombineToBSL(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
   EVT VT = N->getValueType(0);
   SelectionDAG &DAG = DCI.DAG;
   SDLoc DL(N);
+  const auto &Subtarget = DAG.getSubtarget<AArch64Subtarget>();
 
   if (!VT.isVector())
     return SDValue();
 
-  // The combining code currently only works for NEON vectors. In particular,
-  // it does not work for SVE when dealing with vectors wider than 128 bits.
-  // It also doesn't work for streaming mode because it causes generating
-  // bsl instructions that are invalid in streaming mode.
-  if (TLI.useSVEForFixedLengthVectorVT(
-          VT, !DAG.getSubtarget<AArch64Subtarget>().isNeonAvailable()))
+  // The combining code works for NEON, SVE2 and SME.
+  if (TLI.useSVEForFixedLengthVectorVT(VT, !Subtarget.isNeonAvailable()) ||
+      (VT.isScalableVector() && !Subtarget.hasSVE2orSME()))
----------------
paulwalker-arm wrote:

Just a note to say we currently have an issue with using `hasSVE2orSME` like this because the presence of SME doesn't necessarily mean we can execute SVE instructions.  I'm going to ignore it for this patch because it'll be fixed in the future and we'll need to check all uses of `hasSVE2orSME` at that point anyway.

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


More information about the llvm-commits mailing list