[llvm] [AArch64] Use brk{a, b} for a lane mask from cttz.elts (PR #178674)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 4 01:27:51 PST 2026


================
@@ -6022,6 +6022,43 @@ static SDValue optimizeIncrementingWhile(SDNode *N, SelectionDAG &DAG,
   return SDValue();
 }
 
+// Match active.lane.mask(cttz.elts(x)) -> brkb(x)
+// Match active.lane.mask(add(cttz.elts(x), 1)) -> brka(x)
+static SDValue optimizeBrk(SDNode *N, SelectionDAG &DAG) {
+  EVT VT = N->getValueType(0);
+
+  // TODO: Do we need to do anything for fixed types post legalization?
+  if (!VT.isScalableVT())
+    return SDValue();
+
+  SDValue Op = N->getOperand(1);
----------------
david-arm wrote:

nit: Can you give this a more meaningful name that indicates which operand you're looking at? The operation has two arguments so it's a bit unclear.

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


More information about the llvm-commits mailing list