[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
Wed Dec 10 03:07:07 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:
This cost will be outdated if https://github.com/llvm/llvm-project/pull/168565 lands. Any mask can expand to:
WAR:
```
diff = (ptrB - ptrA) / eltSize
cmp = setcc diff, 0, le
upper_bound = select cmp, -1, diff
mask = get_active_lane_mask lane_offset, upper_bound
```
RAW
```
diff = abs((ptrB - ptrA) / eltSize)
cmp = setcc diff, 0, eq
upper_bound = select cmp, -1, diff
mask = get_active_lane_mask lane_offset, upper_bound
```
https://github.com/llvm/llvm-project/pull/167551
More information about the llvm-commits
mailing list