[llvm] [Analysis][AArch64] Add cost model for loop.dependence.{war/raw}.mask (PR #167551)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 03:18:06 PST 2025


================
@@ -2190,6 +2190,69 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
       // Otherwise, fallback to default scalarization cost.
       break;
     }
+    case Intrinsic::loop_dependence_raw_mask:
+    case Intrinsic::loop_dependence_war_mask: {
+      // Compute the cost of the expanded version of these intrinsics:
+      //    ; Figure out if there's overlap between the pointers.
+      //    diff = (ptrB - ptrA) / eltSize ; read-after-write will use the
+      //        absolute difference
+      //    cmp = diff <= 0 ; read-after-write will check for equality
+      //        with 0
+      //    ; Create a mask with each lane < diff active. This is essentiallly
+      //        an active lane mask between 0 and diff.
+      //    diff_splat = splat diff to <Y x i64>
+      //    steps = stepvector <Y x i64>
+      //    diff_mask = steps <= diff_splat
+      //    ; OR that diff mask with the comparison result, so that each lane is
+      //        active if it's less than diff or there was no overlap in the
+      //        first place. Otherwise the lane is inactive.
+      //    cmp_splat = splat cmp to <Y x i1>
+      //    result = or cmp_splat diff_mask
----------------
MacDue wrote:

I've now updated this PR to match the expansion added in https://github.com/llvm/llvm-project/pull/168565. 

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


More information about the llvm-commits mailing list