[PATCH] D79100: [LV] Emit new IR intrinsic llvm.get.active.mask for tail-folded loops
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 29 04:50:56 PDT 2020
fhahn added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/VPlan.cpp:425
+
+ Instruction *Call = Builder.CreateIntrinsic(
+ Intrinsic::get_active_lane_mask, {PredTy, ScalarBTC->getType()},
----------------
IIUC we want the first lanes of both the BTC and the IV, right?
If that's the case, I think it would be more straight-forward to just request the specific lane when looking up the values, .e.g something like:
```
// Get first lane of vector induction variable.
Value *VIVE0 = State.get(getOperand(0), {Part, 0});
// Get first lane of backedge-taken-count.
Value *ScalarBTC = State.get(getOperand(1), {Part, 0});
auto *Int1Ty = Type::getInt1Ty(Builder.getContext());
auto *PredTy = VectorType::get(Int1Ty, State.VF);
Instruction *Call = Builder.CreateIntrinsic(
Intrinsic::get_active_lane_mask, {PredTy, ScalarBTC->getType()},
{VIVE0, ScalarBTC}, nullptr, "active.lane.mask");
State.set(this, Call, Part);
```
This should have the advantage of re-using some scalar values, if they have been requested already by other recipes.
(Note: this currently crashes unfortunately, as getting lanes for defs managed by VPTransformState does not work, but I put up D80787 to fix that)
================
Comment at: llvm/test/Transforms/LoopVectorize/ARM/tail-loop-folding.ll:81
; PREDFLAG: vector.body:
-; PREDFLAG: %wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0v4i32(
-; PREDFLAG: %wide.masked.load1 = call <4 x i32> @llvm.masked.load.v4i32.p0v4i32(
+; PREDFLAG: %[[INDUCTION:induction.*]] = add <4 x i64> %broadcast.splat, <i64 0, i64 1, i64 2, i64 3>
+; PREDFLAG: %[[ELEM0:.*]] = extractelement <4 x i64> %[[INDUCTION]], i64 0
----------------
We should also have a test where the unroll-factor/interleave-count > 1 with `llvm.get.active.lane.mask` (unless that's not possible at the moment)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79100/new/
https://reviews.llvm.org/D79100
More information about the llvm-commits
mailing list